25 A Famous Music Composer

来源:互联网 发布:高等电网络理论 编辑:程序博客网 时间:2024/06/06 07:04

A Famous Music Composer

时间限制:1000 ms  |  内存限制:65535 KB
难度:1
描述
Mr. B is a famous music composer. One of his most famous work was his set of preludes. These 24 pieces span the 24 musical keys (there are musically distinct 12 scale notes, and each may use major or minor tonality). The 12 distinct scale notes are: 
 A    A#=Bb B       C      C#=DbD      D#=Eb E      F       F#=Gb G      G#=Ab

Five of the notes have two alternate names, as is indicated above with equals sign. Thus, there are 17 possible names of scale notes, but only 12 musically distinct notes. When using one of these as the keynote for a musical key, we can further distinguish between major and minor tonalities. This gives 34 possible keys, of which 24 are musically distinct. 
In naming his preludes, Mr. B used all the keys except the following 10, which were named instead by their alternate names: 
 Ab minor A# majorA# minor C# major Db minor D# major D# minorGb major Gb minor G# major 
Write a program that, given the name of a key, give an alternate name if it has one, or report the key name is unique. 
输入
Each test case is described by one line having the format "note tonality", where "note" is one of the 17 names for the scale notes given above, and "tonality" is either "major" or "minor" (quotes for clarify).
输出
For each case output the required answer, following the format of the sample.
样例输入
Ab minorD# majorG minor
样例输出
             Case 1: G# minor
             Case 2: Eb major
             Case 3: UNIQUE

#include<stdio.h>
#include<string.h>
int str(char *p1,char *p2)
{
 int i,j=1;
 char t[][10]={"A#","Bb","C#","Db","D#","Eb","F#","Gb","G#","Ab"};
 for(i=0;i<10;i++)
 {
  
  if(strcmp(p1,t[i])==0)
  {
   if(i&1) printf("%s %s\n",t[i-1],p2);
   else printf("%s %s\n",t[i+1],p2);
   j=0;
  }  
 }
 if(j) printf("UNIQUE\n");
}
int main()
{
 int k=0;
 char a[10],b[10],*p1,*p2;  //数组刚开始开小了;
 while(scanf("%s %s",a,b)!=EOF)
 {
  printf("Case %d: ",++k);
  p1=a;
  p2=b;
  str(p1,p2);
 } return 0;
}

 

刚学会用函数调用,练练手。

 
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 三周岁半宝宝入园后不合群怎么办 数学懒于思考的孩子怎么办 2岁宝宝爱哭不讲道理怎么办 孩子不讲道理一直哭怎么办 白天不烧晚上烧怎么办 两岁宝宝出虚汗怎么办 两岁宝宝出水痘怎么办 两岁宝宝爱看手机怎么办 两岁宝宝太好动怎么办 五岁宝宝不会数数怎么办 四岁宝宝算数不好怎么办 两个月宝宝体内有火怎么办 两个月宝宝有火怎么办 2岁宝宝起眼屎怎么办 一周岁的宝宝皮肤过敏怎么办 两岁宝宝脾气倔不听话怎么办 22个月宝宝打人怎么办 两岁宝宝会打人怎么办 3岁哭闹倔强不止怎么办 我儿子二十三岁不爱说话怎么办 2岁宝宝不听话脾气大怎么办 2岁宝宝调皮不听话怎么办 2岁的宝宝不听话怎么办 2岁宝宝总是不听话怎么办 2岁宝宝淘气不听话怎么办 两岁宝宝不听大人的话怎么办? 来月经奶量减少怎么办 月经来了奶少怎么办 来例假奶水少了怎么办 两岁宝宝吐口水怎么办 3岁宝宝不愿自己吃饭怎么办 婆家的人很烦人怎么办 三十了还没结婚怎么办 两岁宝贝断奶粉怎么办 宝宝断了母乳不吃奶粉怎么办 一岁宝宝不爱吃辅食怎么办 断奶后宝宝抗拒奶瓶怎么办 两岁宝宝断奶后不喝奶粉怎么办 两岁宝宝断奶不吃奶粉怎么办 宝宝断奶妈妈涨奶怎么办 三岁宝宝智商低怎么办