hdu 42445A Famous Music Composer

本文介绍了一个简单的程序设计案例,该程序用于解决音乐键名的转换问题。通过对17种音符名称及其对应的等价名称进行映射,当输入一个包含音符和调性的键名时,程序能够输出其等价的键名或者表明该键名是独一无二的。此程序通过比较和替换等价键名,提供了一种有效的方法来处理音乐理论中常见的键名转换。

A Famous Music Composer

Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 460Accepted Submission(s): 271


Problem Description
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:


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:


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.


Input
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).


Output
For each case output the required answer, following the format of the sample.


Sample Input

 
Ab minor D# major G minor


Sample Output

 
Case 1: G# minor Case 2: Eb major Case 3: UNIQUE

A#=Bb 表示这2个串 可以互换

输入2个串 把第一个串换掉后输出 第二个直接输出 如果第一个换不掉 输出UNIQUE

Source

#include<stdio.h>
#include<string.h>
struct haha
{
char str1[10];
char str2[10];
}a[20];


int main()
{
int cas=0,i;
char s1[100],s2[100];
strcpy(a[1].str1,"A#");
strcpy(a[1].str2,"Bb");
strcpy(a[2].str1,"Bb");
strcpy(a[2].str2,"A#");
strcpy(a[3].str1,"C#");
strcpy(a[3].str2,"Db");
strcpy(a[4].str1,"Db");
strcpy(a[4].str2,"C#");
strcpy(a[5].str1,"D#");
strcpy(a[5].str2,"Eb");
strcpy(a[6].str1,"Eb");
strcpy(a[6].str2,"D#");
strcpy(a[7].str1,"F#");
strcpy(a[7].str2,"Gb");
strcpy(a[8].str1,"Gb");
strcpy(a[8].str2,"F#");
strcpy(a[9].str1,"G#");
strcpy(a[9].str2,"Ab");
strcpy(a[10].str1,"Ab");
strcpy(a[10].str2,"G#");

while(scanf("%s %s",s1,s2)!=EOF)
{
for(i=1;i<=10;i++)
{
if(strcmp(s1,a[i].str1)==0) break;
}
if(i>10) printf("Case %d: UNIQUE\n",++cas);
else printf("Case %d: %s %s\n",++cas,a[i].str2,s2);
}
return 0;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值