描述
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. makefile教程网址

    http://www.cnblogs.com/wang_yb/p/3990952.html

  2. 【Nhibernate】入门 踩雷篇

    总结(喜欢写在前面,记性不好老忘记解决问题时的思路): 使用框架一般不会完整的看文档,直接上来就搞,踩雷是必须的,重要的是遇到雷的时候要快速变换思路,是不是姿势不对(文件位置不对) 提高解决问题的速度 ...

  3. 命令行插入含有中文的sql文件,报错ERROR 1366 (HY000): Incorrect stringvalue:

    --以下是插入语句: insert into sms_inbox values('123456','123456', 'cd', sysdate(), '今天天 气很好', 1, sysdate(), ...

  4. (菜鸟要飞系列)一,基于Asp.Net MVC5的后台管理系统(前言)

    今天真是个郁闷的日子,因为老师两个星期前给我的一个任务,用递归算法将Oracle数据库中用户信息及权限显示在jquery-treeView上,网上虽然有大神写出了这类算法,但是不贴全部代码,真的很难跟 ...

  5. topcoder 673

    DiV1 300:给一组士兵再给一组战马都有权值. 安排战马的顺序的方案数,是第一个士兵和其战马的权值乘积最大. 做法:随便暴力就好. 枚举战马和第一个士兵匹配.其他士兵按权值从大到小排序,战马权值按 ...

  6. ASP.NET Web - 开篇

    ASP.NET运行库 服务器系统上需要ASP.NET运行库.如果系统上有IIS,就会在安装.NET Framework时为服务器配置ASP.NET运行库.开发过程中,不需要IIS,因为VS发布了自己的 ...

  7. Oracle 异常处理

    1.什么是异常 在PL/SQL中的一个警告或错误的情形都可被称为异常.包括编译时错误(PLS)和运行时错误(ORA).一个异常通常包含一个错误代码和错误文本,分别指示异常的编号和具体错误信息.   异 ...

  8. Week1 Team Homework #1: Study the projects done by previous student groups

      我们研究了学长的项目:百度3D地图API的调用.下面是我们对该项目的一些看法: 优点: 界面清晰 各类之间调用及其他关系容易理清. 缺点: 前段html代码过于冗杂,很多(div)块间的层次关系不 ...

  9. Getting Started with Java

    “学前”说明:<Learn Java for Android>这本书内容很多,都是精华,建议大家看英文版的.在这里我不打算一一总结书中的内容,书中每章节后面的exercises都很好,非常 ...

  10. Zabbix实现告警分级

    Zabbix中trigger的severity的值定义了trigger的不同严重程度,其中severity默认的6个值为 Not classified, Information, Warning, A ...