25-A Famous Music Composer

内存限制:64MB
时间限制:1000ms
Special Judge: No

accepted:4
submit:9

题目描述:

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 题目大意:
  ①、每一行,给你两个字符串,判断第一个字符串是否属于表格一中有“=”符号的字符串,属于就输出与之相同的字符串,至于第二个字符串,照抄下来就行了,但是如果不属于有“=”连接的字符串,就要输出UNIQUE 分析:
  ①、我们可以看出具有“=”关系的前三个字符第一个元素差1,而第二个相对固定,酱紫考虑问题就简洁很多了 核心代码:  
 if(s1[] == '#')
{
if(s1[] == 'G')
printf("Ab %s\n", s2);
else
printg("%cb %s\n", s1[]+, s2);
}
else if(s1[] == 'b')
{
if(s1[] == 'A')
printf("G# %s\n", s2);
else
printf("%c# %s\n", s1[]-, s2);
}
else
{
printf("UNIQUE\n");
}

C/C++代码实现(AC):

 #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <stack> using namespace std; int main ()
{
char s1[], s2[];
int cnt = ;
while(~scanf("%s %s", &s1[], &s2[]))
{
printf("Case %d: ", cnt ++);
if(s1[] == '#')
{
if(s1[] == 'G')
{
printf("Ab %s\n", s2);
}
else
{
printf("%cb %s\n", s1[]+, s2);
}
}
else if(s1[] == 'b')
{
if(s1[] == 'A')
{
printf("G# %s\n", s2);
}
else
{
printf("%c# %s\n", s1[]-, s2);
}
}
else
{
printf("UNIQUE\n");
}
}
return ;
}

nyoj 25-A Famous Music Composer(字符串)的更多相关文章

  1. NYOJ 25 A Famous Music Composer

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

  2. 25.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 ...

  3. 07-语言入门-07-A Famous Music Composer

    题目地址: http://blog.csdn.net/sevenmit/article/details/8231994  描述 Mr. B is a famous music composer. On ...

  4. 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 ...

  5. nyoj25-A Famous Music Composer

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

  6. NYOJ 305 表达式求值 (字符串处理)

    题目链接 描述 Dr.Kong设计的机器人卡多掌握了加减法运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min(20,23)的值是20 ,add(10,98) 的值是108等等.经过训练, ...

  7. NYOJ 35 表达式求值 (字符串处理)

    题目链接 描述 ACM队的mdd想做一个计算器,但是,他要做的不仅仅是一计算一个A+B的计算器,他想实现随便输入一个表达式都能求出它的值的计算器,现在请你帮助他来实现这个计算器吧. 比如输入:&quo ...

  8. PAT A1110 Complete Binary Tree (25 分)——完全二叉树,字符串转数字

    Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each in ...

  9. PAT A1028 List Sorting (25 分)——排序,字符串输出用printf

    Excel can sort records according to any column. Now you are supposed to imitate this function. Input ...

随机推荐

  1. 爬虫2:html页面+beautifulsoap模块+post方式+demo

    爬取html页面,有时需要设置参数post方式请求,生成json,保存文件中. 1)引入模块 import requests from bs4 import BeautifulSoup url_ = ...

  2. 《疯狂java-突破程序员基本功的16课 》笔记总结

    本人最近读完<疯狂java-突破程序员基本功的16课 >读完后,感觉对java基础又有了新的认识,在这里总结一下:一.数组与内存控制 1.1 数组初始化     java语言的数组是静态的 ...

  3. 三种常见字符编码:ASCII、Unicode和UTF-8

    什么是字符编码? 计算机只能处理数字,如果要处理文本,就必须先把文本转换为数字才能处理.最早的计算机在设计时采用8个比特(bit)作为一个字节(byte),所以,一个字节能表示的最大的整数就是255( ...

  4. 就改了get,却不让我set?——Java内省机制的神奇行为举止一例

    [相关类库]org.apache.commons.beanutils.BeanUtils,提供对Java反射和自省API的包装,其中底层使用到了Java的内省方法.[内省的一般应用形式]通过类Intr ...

  5. C#版ASP.NET Web API使用示例

    为更好更快速的上手Webapi设计模式的接口开发,本文详细解释了在Web API接口的开发过程中,我们可能会碰到各种各样的问题总结了这篇,希望对大家有所帮助. 1:在接口定义中确定MVC的get或者P ...

  6. 5.Linux文件管理相关命令(下)

    1.文件管理之:联网下载文件(wget.curl).文件上传与下载(rz.sz) 1.wget命令 1.CentOS7 系统最小化安装默认没有wget命令,需要进行安装 [root@oldboyedu ...

  7. 安装配置 Android Studio

    概述 Android Studio 本身应该是开箱即用的,但是由于 dl.google.com 访问太慢,导致了这样那样的问题,因此我们只需要改一下 hosts 就行了 具体步骤 在Ping检测网站查 ...

  8. 9i oracle数据库迁移到11G(exp)

    这个是之前生产上打算迁移的文档,后面离职了没有在停机迁移,但是测试过几次没有问题,其中需要把9I的110,120库迁移到11g一个数据库中,但是110,120库之间有相同的表名字,以及有DBLINK. ...

  9. LeetCode 2: single-number II

    Given an array of integers, every element appears three times except for one. Find that single one. ...

  10. Java基于回调的观察者模式详解

    本文由“言念小文”原创,转载请说明文章出处 一.前言 什么是回调?回调如何使用?如何优雅的使用?本文将首先详解回调的原理,然后介绍回调的基本使用方法,最后介绍基于回调的“观察者模式”实现,演示如何优化 ...