nyoj 25-A Famous Music Composer(字符串)
25-A Famous Music Composer
内存限制:64MB
时间限制:1000ms
Special Judge: No
accepted:4
submit:9
题目描述:
A | A#=Bb | B | C | C#=Db | D | D#=Eb | E | F | F#=Gb | G | G#=Ab |
Ab minor | A# major | A# minor | C# major | Db minor |
D# major | D# minor | Gb major | Gb minor | G# major |
输入描述:
- 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(字符串)的更多相关文章
- NYOJ 25 A Famous Music Composer
A Famous Music Composer 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 Mr. B is a famous music composer. O ...
- 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 ...
- 07-语言入门-07-A Famous Music Composer
题目地址: http://blog.csdn.net/sevenmit/article/details/8231994 描述 Mr. B is a famous music composer. On ...
- 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 ...
- nyoj25-A Famous Music Composer
A Famous Music Composer 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 Mr. B is a famous music composer. One ...
- NYOJ 305 表达式求值 (字符串处理)
题目链接 描述 Dr.Kong设计的机器人卡多掌握了加减法运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min(20,23)的值是20 ,add(10,98) 的值是108等等.经过训练, ...
- NYOJ 35 表达式求值 (字符串处理)
题目链接 描述 ACM队的mdd想做一个计算器,但是,他要做的不仅仅是一计算一个A+B的计算器,他想实现随便输入一个表达式都能求出它的值的计算器,现在请你帮助他来实现这个计算器吧. 比如输入:&quo ...
- 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 ...
- PAT A1028 List Sorting (25 分)——排序,字符串输出用printf
Excel can sort records according to any column. Now you are supposed to imitate this function. Input ...
随机推荐
- opencv::Mat属性
OpenCV支持JPG.PNG.TIFF等常见格式图像文件加载 加载图像 Mat imread( const String& filename, int flags = IMREAD_COLO ...
- CSS3、jQuery实现3D翻书动画
使用CSS3 ,jQuery实现点击翻书动画效果,完整效果可在firefox中查看 HTML <div class="desktop"> <div class=& ...
- {每日一题}:tcp协议实现简单的文件下载器(单任务版)
文件下载器客户端 这个版本的只是为了方便回顾一下TCP客服端,服务端的创建流程,缺点就是 服务器一次只能让一个人访问下载,过两个写个使用面向对象写一个多线程版的强化一下. from socket i ...
- JS单例对象与构造函数对象的区别
JavaScript对象有几种: 内置对象如Global,Math对象等等. 本地对象如Object.Function.Array.String.Boolean.Number.Date.RegExp. ...
- <编译原理 - 函数绘图语言解释器(1)词法分析器 - python>
<编译原理 - 函数绘图语言解释器(1)词法分析器 - python> 背景 编译原理上机实现一个对函数绘图语言的解释器 - 用除C外的不同种语言实现 解释器分为三个实现块: 词法分析器: ...
- Java基础(七)泛型数组列表ArrayList与枚举类Enum
一.泛型数组列表ArrayList 1.在Java中,ArrayList类可以解决运行时动态更改数组的问题.ArrayList使用起来有点像数组,但是在添加或删除元素时,具有自动调节数组容量的功能,而 ...
- Flask解析(二):Flask-Sqlalchemy与多线程、多进程
Sqlalchemy flask-sqlalchemy的session是线程安全的,但在多进程环境下,要确保派生子进程时,父进程不存在任何的数据库连接,可以通过调用db.get_engine(app= ...
- UART和RS232/RS485的关系是什么?
串口通讯是电子工程师和嵌入式开发工程师面对的最基本问题,RS232则是其中最简单最常用的通讯方式.但是初学者往往搞不清有关的名词如UART和RS232或RS485之间是什么关系,因为它们经常被放到语句 ...
- springboot(3)——配置文件和自动配置原理详细讲解
原文地址 目录 概述 1. 配置文件作用 2.配置文件位置 3.配置文件的定义 3.1如果是定义普通变量(数字 字符串 布尔) 3.2如果是定义对象.Map 3.3如果是定义数组 4.配置文件的使用 ...
- CVE-2019-0708: Windows RDP远程漏洞无损检测工具下载
CVE-2019-0708: Windows RDP远程漏洞无损检测工具下载 0x00下载链接 https://free.360totalsecurity.com/CVE-2019-0708/dete ...