A Famous Music Composer
来源:互联网 发布:软件编程就业前景 编辑:程序博客网 时间:2024/05/29 16:08
- 描述
- 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 majorCase 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;}
题目标程:#include<iostream>#include<string>using namespace std;string trans(string a){string b="";if(a[1]=='#'){b+=char((a[0]-'A'+1)%7+'A');b+='b';}else{b+=char((a[0]-'A'+6)%7+'A');b+='#';}return b;}int main(){string a,b;for(int t=1; cin>>a>>b; t++){cout<<"Case "<<t<<": ";if(a.length()==1)cout<<"UNIQUE"<<endl;elsecout<<trans(a)<<" "<<b<<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
- Linux内存、性能诊断中vmstat命令的详解
- PAT 1004. Counting Leaves (30)
- 侧边固定导航栏
- How to embed Lua in C++ on Visual Studio
- Python 爬虫 队列
- A Famous Music Composer
- 启动和停止Java应用程序的Shell脚本
- ecshop不同的支付方式对应不同的价格折扣
- (4.2.2.3)【android开源工具】【Android UI设计与开发】第18期:滑动菜单栏(三)SlidingMenu动画效果的实现
- 编程能力层次模型
- C/C++内存对齐
- 堆和栈的区别(转过无数次的文章)
- ACM中的Apache与Tomcat集成配置
- (4.2.3)【android开源工具】Android快速开发系列 10个常用工具类