[4245]:A Famous Music Composer

来源:互联网 发布:淘宝女装代发货源 编辑:程序博客网 时间:2024/06/02 05:44

这里写图片描述
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

解题思路:这道题好像说了很多东西,刚开始也不知道题目在表达什么,不过细看,其实就是说,如果输入的符号有等价的符号,则输出它的等价符号和对该符号的评价(个人这么理解的,只是为了方便理解),没有等价的,则视为特殊符号(UNIQUE),总的来说,第二个表格没有任何作用
这里本人用的是strcmp()函数

/*  author : Yangchengfeng*/#include<stdio.h>#include<string.h>#define N 3#define M 7int main(){    char test[N], str[M];    int i = 0;    while(scanf("%s%s", test, str)!=EOF){        i++;        if(!strcmp(test, "A") || !strcmp(test, "B") || !strcmp(test, "C") || !strcmp(test, "D") || !strcmp(test, "E") || !strcmp(test, "F") || !strcmp(test, "G")){            printf("Case %d: UNIQUE\n", i);        } else {            if(!strcmp(test, "A#")){                printf("Case %d: Bb %s\n", i, str);            }            if(!strcmp(test, "Bb")){                printf("Case %d: A# %s\n", i, str);            }            if(!strcmp(test, "C#")){                printf("Case %d: Db %s\n", i, str);            }            if(!strcmp(test, "Db")){                printf("Case %d: C# %s\n", i, str);            }            if(!strcmp(test, "D#")){                printf("Case %d: Eb %s\n", i, str);            }            if(!strcmp(test, "Eb")){                printf("Case %d: D# %s\n", i, str);             }            if(!strcmp(test, "F#")){                printf("Case %d: Gb %s\n", i, str);            }            if(!strcmp(test, "Gb")){                printf("Case %d: F# %s\n", i, str);             }            if(!strcmp(test, "G#")){                printf("Case %d: Ab %s\n", i, str);             }            if(!strcmp(test, "Ab")){                printf("Case %d: G# %s\n", i, str);             }        }    }    return 0;}

这里写图片描述
这里写图片描述

0 0
原创粉丝点击