描述

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>
int main()
{
    char s[100];
    int i,n,c=1;
    while(gets(s))
    {
        n=strlen(s);
        printf("Case %d: ",c++);
            if(s[1]=='#')
            {
                if(s[0]=='G')
                    printf("Ab");
                else
                    printf("%cb",s[0]+1);
                    for(i=2;i<n;i++)
                        printf("%c",s[i]);
                    printf("\n");
            }
            if(s[1]=='b')
            {
                if(s[0]=='A')
                    printf("G#");
                else
                    printf("%c#",s[0]-1);
                    for(i=2;i<n;i++)
                        printf("%c",s[i]);
                    printf("\n");
            }
            if(s[1]==' ')
            printf("UNIQUE\n");
    }
    return 0;
}最优程序#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;
}

转载于:https://www.cnblogs.com/AquamarineOnly/p/5584430.html

A Famous Music Composer相关推荐

  1. NYOJ - A Famous Music Composer

    A Famous Music Composer 时间限制: 1000 ms  |           内存限制: 65535 KB 难度: 1 描述 Mr. B is a famous music c ...

  2. composer PHP Fatal error: Allowed memory size of 报错解决

    执行以下命令(安装多线程) php composer.phar require hirak/prestissimo 出现以下提示 PHP Fatal error: Allowed memory siz ...

  3. CentOS7安装Composer

    1.使用命令下载 curl -sS https://getcomposer.org/installer | php 2.下载之后设置环境变量 mv composer.phar /usr/local/b ...

  4. composer爆错:zlib_decode():data error

    昨晚用nginx运行Yii的一个开源小项目,结果composer安装依赖一直报错,如下 Failed to decode response: zlib_decode(): data error 如果遇 ...

  5. compser可以检查php扩展吗,composer扩展

    ## 一些简单的thinkphp扩展 1. 正则表达式的扩展: PHP7以上: ``` composer req gherkins/regexpbuilderphp ``` PHP5 ``` comp ...

  6. 简单安装与使用composer

    1.下载composer.exe工具,然后进行安装 这一步需要找到你使用的php版本文件 2.windows+r     cmd  输入composer 安装中国镜像,提高使用效率 https://p ...

  7. 用composer安装laravel-bjyblog

    前面讲了两行命令composer的安装,现在我们来操作一下composer安装基于laravel的博客laravel-bjyblog.测试环境是linux,bt面板,php7.2安装扩展fileinf ...

  8. Packagist / Composer 中国全量镜像

    Packagist 镜像 请各位使用本镜像的同学注意: 本镜像已经依照 composer 官方的数据源安全策略完全升级并支持 https 协议!请各位同学 按照下面所示的两个方法将 http://pa ...

  9. laravel项目composer安装

    1.下载 Composer (https://pkg.phpcomposer.com/#how-to-install-composer) 安装前请务必确保已经正确安装了 PHP.打开命令行窗口并执行 ...

最新文章

  1. GT Transceiver的电源控制
  2. mysql定制化_【MySQL技巧】定制你的MySQL命令行-阿里云开发者社区
  3. express 连接 moogdb 数据库
  4. codeigniter文件上传问题
  5. Abp vNext 二进制大对象系统(BLOB)
  6. 华农计算机学院院长,华农大生命科学技术学院副院长到武生院任职
  7. 多次fork问题(python 版)
  8. Java设计模式(详细待续)(转)
  9. 上下班成最远的距离...
  10. 我的个人作品——室内效果图
  11. Aspose.PDF使用教程:使用 C# 创建多列 PDF 文档
  12. 威密 android,勇士这赛季的结局,是否开始就已注定
  13. python opencv 函数库说明
  14. 地震观测仪器的历史和发展趋势(三)
  15. unity控制物体移动和转向
  16. Charles手机的代理配置与证书的安装
  17. java容器~面试知识点整理
  18. 【uniapp 动态设置 起始页 默认展示页面 】
  19. MC7812BTG详细参数介绍
  20. 知道创宇 二级安全公司 骗取面试人源码,长见识了啊。

热门文章

  1. html5倒计时秒杀怎么做,vue 设计一个倒计时秒杀的组件
  2. python里unexpected eof while parsing_使用Python编程时的10个注意事项
  3. Python攻克之路-random模块
  4. 新的起点,新的生活!加油!
  5. 老子《道德经》第四十一章
  6. AVP 6目GoPro全景拼接
  7. 基于OpenCV平滑图像
  8. MongoDB 聚合操作
  9. 解密汽车全景行车安全系统的前世和今生——第二讲:原理讲解
  10. Android Studio相见恨晚的操作锦集