nyoj 25 A Famous Music Composer

来源:互联网 发布:域名代理商哪个好 编辑:程序博客网 时间:2024/05/29 14:29

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# minorCase 2: Eb majorCase 3: UNIQUE

这道题只需把第一个表中相互对应的字母换一下,再输出就行了。比如C#需要换成Db(有=的),后面的不变输出,像A,B,C,D,E,F,G这个单个的,因为表中没有对应的(就是它们后面没有=的),就输出UNIQUE.

#include<stdio.h>#include<string.h>int main(){int n=1,i,l;char s[10];while(gets(s)){printf("Case %d: ",n++);l=strlen(s);if(s[1]==' ')printf("UNIQUE\n");else{if(s[1]=='#'){if(s[0]=='G'){s[0]='A';s[1]='b';}else{s[0]+=1;s[1]='b';}}else{if(s[0]=='A'){s[0]='G';s[1]='#';}else{s[0]-=1;s[1]='#';}}puts(s);}}return 0;}


 

0 0
原创粉丝点击