描述
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. [ios]scrollView实现移动与缩放

    实现滑动 1.在viewDidLoad中对scrollview的contentSize属性赋值 告诉他滑动范围. 实现缩放 1.在storyboard的scrollview的attribute标签中设 ...

  2. mysql5.5 Replication 主从同步

    mysql5.5 Replication 主从同步 ------------------[主]------------------[mysqld]server-id=1 log-bin=mysql-b ...

  3. C++中用辗转相除法求两个数的最大公约数和最小公倍数

    两个数的最大公约数:不能大于两个数中的最小值,算法口诀:小的给大的,余数给小的,整除返回小的,即最大公约数,(res=max%min)==0?  max=min,min=res return min; ...

  4. Leetcode-Read N Characters Given Read4 II

    The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actu ...

  5. DB天气app冲刺二阶段第十天

    昨天困到不行了 所以就写了那么几句..所以今天好好写写了要.. 今天的收获了一个很重要的问题 就还是api接口的事情,以前的那个接口虽然能用但是总是不稳定,今天由决定百度的一下然后就发现了一个很好用的 ...

  6. window对象的属性方法名造成的命名冲突

    事件起因: 一次开发中需要获取一个数组的长度,写下如此代码 function func(arr){ length = arr.length; ......//相关操作 } 程序在chrome下正常运行 ...

  7. Win64位操作系统无法运行暗黑2战网D2GS的解决办法

    前几天想在我的Win7 x64系统里做个战网自己玩,搭建完毕后进入战网创建房间出现经典的问题,“排队1”. 原因很清楚,就是D2GS无法启动:但是使用之前的各种办法尝试后无果,后来查看D2GS同目录下 ...

  8. C# 读取枚举描述信息实例

    using System;using System.Collections;using System.Collections.Generic;using System.Linq;using Syste ...

  9. 字符串匹配--kmp算法原理整理

    kmp算法原理:求出P0···Pi的最大相同前后缀长度k: 字符串匹配是计算机的基本任务之一.举例,字符串"BBC ABCDAB ABCDABCDABDE",里面是否包含另一个字符 ...

  10. Unity3D研究院之IOS本地消息通知LocalNotification的使用

    原地址:http://www.xuanyusong.com/archives/2632   现在的游戏里一般都会有本地消息,比如每天定时12点或者下午6点告诉玩家进入游戏领取体力.这种东西没必要服务器 ...