A Famous Music Composer
来源:互联网 发布:腾讯儿童智能台灯知乎 编辑:程序博客网 时间:2024/06/08 14:56
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#=AbFive 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# majorWrite 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 major
Case 3: UNIQUE
代码实现:
#include<iostream>
using namespace std;
int main()
{
int i=0;
char a[5],b[10];
while(cin>>a>>b)
{
cout<<"Case "<<++i<<": ";
if(a[1]=='#')
{
if(a[0]!='G')
{
a[0]=a[0]+1;
cout<<a[0]<<'b'<<" "<<b<<endl;
}
else
cout<<'A'<<'b'<<" "<<b<<endl;
}
else if(a[1]=='b')
{
if(a[0]!='A')
{
a[0]=a[0]-1;
cout<<a[0]<<'#'<<" "<<b<<endl;
}
else
{
cout<<'G'<<'#'<<" "<<b<<endl;
}
}
else
cout<<"UNIQUE"<<endl;
}
return 0;
}实现思路:本题就是按照规定输出字符的别名,首先观察输入的所有情况的共同点,然后分类讨论每种情况的输出,其实很简单,只是需要细心比对。
阅读全文
0 0
- A Famous Music Composer
- A famous music composer
- A Famous Music Composer
- A Famous Music Composer
- A Famous Music Composer
- A Famous Music Composer
- A Famous Music Composer
- A Famous Music Composer
- A Famous Music Composer
- A Famous Music Composer(map)
- NYOJ - A Famous Music Composer
- 25 A Famous Music Composer
- HDU4245:A Famous Music Composer
- NYOJ25 A Famous Music Composer
- NY25 A Famous Music Composer
- 25 A Famous Music Composer
- HDU4245 A Famous Music Composer
- ACM-A Famous Music Composer
- 11.CacheManager源码分析
- 微签(2)--php后台部分源码分析
- Zcash零币挖矿教程Windows系统N卡
- Android 获取系统内的应用信息
- python文件操作 API整理
- A Famous Music Composer
- 一个简单却很炫的LoadingView
- CodeM资格赛E 数码 题解
- 关于手机数据库的访问过程中遇到的一个坑
- [LeetCode] 166. Fraction to Recurring Decimal
- oracle创建新用户
- 神经网络基础知识
- 语音识别关键技术公开,人机交互这么做就对了!
- 答案自己写的