南阳oj 25 A Famous Music Composer (水题,字符串替换问题)
来源:互联网 发布:中联汽车电子公司 知乎 编辑:程序博客网 时间:2024/05/17 06:51
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 majorCase 3: UNIQUE
题意:
给定几串字符,输出变化后的 字符串。
思路:看题上的说明,实话实说,关键在于看题,题目不容易看懂。
对应法则:即除了B E外都存在A# ----Bb 类似的组合对应方式。
Ab----G#
G#----Ab
A#----Bb
Bb----A#
C#----Db
Db----C#
D#----Eb
Eb----D#
F#----Gb
Gb----F#
难点:
关键是读懂题 case的数值的变化 可以通过 标记的方法 解决
作者:dingjiceo
代码如下:
<pre name="code" class="cpp">#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){int i,d=1,flag;char a[1000];while(gets(a)){flag=0;printf("Case %d: ",d);d++;if(a[0]=='A'&&a[1]=='b') { a[0]='G'; a[1]='#';}else if(a[0]=='A'&&a[1]=='#'){ a[0]='B'; a[1]='b';}else if(a[0]=='B'&&a[1]=='b') { a[0]='A'; a[1]='#';}else if(a[0]=='C'&&a[1]=='#') { a[0]='D'; a[1]='b';}else if(a[0]=='D'&&a[1]=='b') { a[0]='C'; a[1]='#';}else if(a[0]=='D'&&a[1]=='#') {a[0]='E'; a[1]='b';}else if(a[0]=='E'&&a[1]=='b') { a[0]='D'; a[1]='#';}else if(a[0]=='G'&&a[1]=='b') { a[0]='F'; a[1]='#';}else if(a[0]=='F'&&a[1]=='#'){ a[0]='G'; a[1]='b';}else if(a[0]=='G'&&a[1]=='#') { a[0]='A'; a[1]='b';}else flag=1;if(flag==0) printf("%s\n",a);else printf("UNIQUE\n");}}
0 0
- 南阳oj 25 A Famous Music Composer (水题,字符串替换问题)
- 南阳oj 题目25 A Famous Music Composer
- 南阳题目25-A Famous Music Composer
- 南阳 oj 语言入门 A Famous Music Composer
- 25 A Famous Music Composer
- 25 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
- nyoj.25 A Famous Music Composer【水题】 2015/03/15
- NYOJ 25 A Famous Music Composer
- NYOJ 题目25 A Famous Music Composer
- Codeforces Beta Round #12 D. Ball (线段树)
- “无法启动程序,因为计算机中丢失MSVCP100D.dll”的解决方案
- C 语言 数字删除
- 一串字符串中出现次数最多的单词
- 第二十七天 春之细雨润物于无形 —Spring的依赖注入
- 南阳oj 25 A Famous Music Composer (水题,字符串替换问题)
- 约瑟夫问题
- Ubuntu下编译安装R全记录
- ASP:Button控件(按钮类型控件)
- 在一个窗口里输出电脑里的所有字体名称(带滚动条)
- VMware虚拟机上网络连接(network type)的三种模式--bridged、host-only、NAT
- HDU 4864Task(多校联合训练1)(贪心)
- OFBiz中JOB的运行机制
- 字符串倒置