描述
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. mysql 连接语句

    在 SELECT 语句中,如果 FROM 子句引用了多个表源或视图,可以使用 JOIN 指示指定的联接操作应在指定的表源或视图之间执行. 一.交叉联接:CROSS JOIN 交叉联接将执行一个叉积(迪 ...

  2. iOS/Objective-C开发 字典NSDictionary的深复制(使用category)

    目标:把NSDictionary对象转换成NSMutableDictionary对象,对象内容是字符串数组,需要实现完全复制(深复制). 如果调用NSDictionary的mutableCopy方法, ...

  3. constructor(构造器)

    当我们创建一个类的时候,如果不自定义构造器,则系统会自动创建一个默认的构造器,也是一个无参构造器用于初始化. 当我们在类的里面创建了自己的构造器,则系统将不会创建默认的构造器,由于需求条件不同,构造器 ...

  4. div+css登陆界面案例

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. SlimDx绘制点图元的问题

    问题:点图元在自己创建的三维环境里渲染不出来,代码如下: GMCustomVertex.PositionNormalColored wellPart = new GMCustomVertex.Posi ...

  6. 2006: [NOI2010]超级钢琴 - BZOJ

    Description小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的音乐. 这架超级钢琴可以弹奏出n个音符,编号为1至n.第i个音符的美妙度为 ...

  7. 2109&2535: [Noi2010]Plane 航空管制 - BZOJ

    Description世博期间,上海的航空客运量大大超过了平时,随之而来的航空管制也频频发生.最近,小X就因为航空管制,连续两次在机场被延误超过了两小时.对此,小X表示很不满意. 在这次来烟台的路上, ...

  8. 把工程部署在tomcat的root路径下

    myeclipse可以右键工程:(eclipse也可以)选择properties->myeclipse->web:把web context-root改成:/然后在用myeclipse部署项 ...

  9. JNI中使用cl命令生成DLL文件

    问题描述:     在使用JNI调用DLL时,首先需要生成DLL文件 问题解决:     (1)现在使用VS2008的cl.exe程序,生成DLL文件 (1.1)cl.exe环境搭建 注:   cl. ...

  10. 设计模式之单实例模式(Singleton)

    原理:将类的构造函数由pubic变为private或者protect,添加获取对象的public 成员函数,返回指向对象的静态指针. 首先来一段简单的代码实现 代码一 class Singleton ...