描述
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#=Db D      D#=Eb E      F      F#=Gb G     G#=Ab
 
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:
Ab minor A# major A# minor C# major Db minor
D# major D# minor Gb major Gb minor G# major
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.
 
 
输入
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 minor
D# major
G minor

样例输出
Case 1: G# minor
Case 2: Eb major
Case 3: UNIQUE
 
#include <stdio.h>
#include <string.h>

#define ARR_LEN 10

int main()
{
     char str1[ARR_LEN];
     char str2[ARR_LEN];
     int index = 0;
     while(scanf("%s %s",str1,str2) != EOF)
     {
          getchar();
          printf("Case %d: ",++index);
          if(strcmp(str1,"A#") == 0)
          {
               printf("Bb %s\n",str2);
          }
          else if(strcmp(str1,"Bb") == 0)
          {
               printf("A# %s\n",str2);
          }
          else if(strcmp(str1,"C#") == 0)
          {
               printf("Db %s\n",str2);
          }
          else if(strcmp(str1,"Db") == 0)
          {
               printf("C# %s\n",str2);
          }
          else if(strcmp(str1,"D#") == 0)
          {
               printf("Eb %s\n",str2);
          }
          else if(strcmp(str1,"Eb") == 0)
          {
               printf("D# %s\n",str2);
          }
          else if(strcmp(str1,"F#") == 0)
          {
               printf("Gb %s\n",str2);
          }
          else if(strcmp(str1,"Gb") == 0)
          {
               printf("F# %s\n",str2);    
          }
          else if(strcmp(str1,"G#") == 0)
          {
               printf("Ab %s\n",str2);
          }
          else if(strcmp(str1,"Ab") == 0)
          {
               printf("G# %s\n",str2);
          }
          else
          {
               printf("UNIQUE\n");
          }
     }
    
     return 0;
}

 
 
注意:
1.英语真心没看懂,英语水平真是渣呀。
2.有更优秀的代码,感觉真心不错:
 
找到了转换的关系,一切交由代码决定。
#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;
          else
               cout<<trans(a)<<" "<<b<<endl;
     }
     return 0;
}
         

07-语言入门-07-A Famous Music Composer的更多相关文章

  1. JavaScript基础入门07

    目录 JavaScript 基础入门07 BOM window对象 Navigator对象 Screen 对象 Location对象 History 对象 JavaScript 基础入门07 BOM ...

  2. 我为什么反对推荐新人编程C/C++语言入门?

    虽然我接触编程以及计算机时间比较早,但是正式打算转入程序员这个行当差不多是大学第四年的事情 从03年接触计算机,07年开始接触计算机编程, 期间接触过的技术包括 缓冲区溢出(看高手写的shellcod ...

  3. 《C语言入门1.2.3—一个老鸟的C语言学习心得》—清华大学出版社炮制的又一本劣书及伪书

    <C语言入门1.2.3—一个老鸟的C语言学习心得>—清华大学出版社炮制的又一本劣书及伪书 [薛非评] 区区15页,有80多个错误. 最严重的有: 通篇完全是C++代码,根本不是C语言代码. ...

  4. 【南阳OJ分类之语言入门】80题题目+AC代码汇总

    小技巧:本文之前由csdn自动生成了一个目录,不必下拉一个一个去找,可通过目录标题直接定位. 本文转载自本人的csdn博客,复制过来的,排版就不弄了,欢迎转载. 声明: 题目部分皆为南阳OJ题目. 代 ...

  5. 《JavaScript语言入门教程》记录整理:入门和数据类型

    目录 入门篇 js介绍 历史 基本语法 数据类型 概述 null 和 undefined 数值 字符串 对象 函数 数组 本系列基于阮一峰老师的<JavaScrip语言入门教程>或< ...

  6. 踢爆IT劣书出版黑幕——由清华大学出版社之《C语言入门很简单》想到的(1)

    1.前言与作者 首先声明,我是由于非常偶然的机会获得<C语言入门很简单>这本书的,绝对不是买的.买这种书实在丢不起那人. 去年这书刚出版时,在CU论坛举行试读推广,我当时随口说了几句(没说 ...

  7. c语言入门教程 / c语言入门经典书籍

    用C语言开始编写代码初级:C语言入门必备(以下两本书任选一本即可) C语言是作为从事实际编程工作的程序员的一种工具而出现的,本阶段的学习最主要的目的就是尽快掌握如何用c语言编写程序的技能.对c语言的数 ...

  8. 【转】c语言入门教程 / c语言入门经典书籍

    用C语言开始编写代码 初级:C语言入门必备 (以下两本书任选一本即可) C语言是作为从事实际编程工作的程序员的一种工具而出现的,本阶段的学习最主要的目的就是尽快掌握如何用c语言编写程序的技能.对c语言 ...

  9. A Famous Music Composer

    描述 Mr. B is a famous music composer. One of his most famous work was his set of preludes. These 24 p ...

随机推荐

  1. Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_100_CI_AS" in the equal to operation.

    ErrorMessage Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" ...

  2. 深入PHP EOF(heredoc)用法详解

    介绍下使用EOF heredoc方式,输出长段内容的方法, <?php $name = '姓名'; print <<<EOT <html> <head> ...

  3. mysql_fetch_row()与mysql_fetch_array()的使用介绍

    mysql_fetch_array --从结果集中取得一行作为关联数组,或数字数组,或二者兼有 说明array mysql_fetch_array ( resource result [, int r ...

  4. CSS去除Chrome浏览器的控件默认样式

    html的input输入框在Chrome浏览器里是有默认样式的,当它获得焦点时,即使你没有为它设置:focus时的样式,Chrome浏览器还是会给它加上蓝色的边框,今天百度找到有个方法可以去除该默认样 ...

  5. ffmpeg mp3转ogg的命令

    ffmpeg.exe -y -i bb.mp3 -acodec libvorbis -ab 128k bb.ogg

  6. WSDL 文档解析

    学习webservice,就离不了WSDL文档,他是我们开发WebService的基础,虽说,现在现在有许多WebService的开源框架使得我们可以根据WSDL生成客户端代码,但是,了解WSDL文档 ...

  7. C++中的mutable关键字

    mutalbe的中文意思是“可变的,易变的”,跟constant(既C++中的const)是反义词. 在C++中,mutable也是为了突破const的限制而设置的.被mutable修饰的变量,将永远 ...

  8. ADO.NET EF实体框架

    ADO.NET 实体框架概述 随着.NET Framework 3.5 SP1和Visual Studio 2008 SP1的正式发布.ADO.NET 实体框架正式来到开发人员的面前,它使开发人员可以 ...

  9. POJ2104 K-th Number Range Tree

    又是区间第k大,这次选择这道题是为以后写线段树套平衡树铺路的.Range Tree可以理解成线段树套vector吧,相当于每个结点多存了对应区间的一个排好序的序列.画一下就会知道空间的消耗是nlogn ...

  10. POJ 3440 Coin Toss(求概率)

    题目链接 题意 :把硬币往棋盘上扔,分别求出硬币占1,2,3,4个格子的时候的概率. 思路 : 求出公式输出,不过要注意输出格式,我还因为输入的时候用了int类型错了好几次..... #include ...