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 ...
随机推荐
- django2-创建项目
方式一:cmd或linux命令行下创建django项目(不常用,此处不做详细介绍) django-admin.py startproject autotest 方式二:使用pycharm专业版创建dj ...
- 【Autofac打标签模式】PropertySource和Value
[ Autofac打标签模式]开源DI框架扩展地址: https://github.com/yuzd/Autofac.Annotation/wiki *:first-child { margin-to ...
- 惊人!Spring5 AOP 默认使用Cglib ?从现象到源码深度分析
Spring5 AOP 默认使用 Cglib 了?我第一次听到这个说法是在一个微信群里: 真的假的?查阅文档 刚看到这个说法的时候,我是保持怀疑态度的. 大家都知道 Spring5 之前的版本 AOP ...
- 从零开始把项目发布到maven仓库中心
sonatype准备操作 注册账号 https://issues.sonatype.org 1. 密码符号规范,并且工记住 新建项目 1. group id 如果你有com域名的所有权可以直接使用,如 ...
- 使用cordova + vue搭建混合app框架
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/zxj0904010228/article ...
- 06 python学习笔记-常用模块(六)
一. 模块.包 1.什么是模块? Python 模块(Module),是一个 Python 文件,以 .py 结尾,包含了 Python 对象定义和Python语句,是用来组织代码的.模块能定义函数 ...
- Java面试题---基础篇
经常阅读一些牛人的基础博以及相关个人经历,你才发现自己真的不够努力,人生路漫漫,希望本人以及看客能走出一条自己不后悔的人生路,骚年 加油!!! 回归正题 一 java基础知识点 1)java面向对 ...
- tp5底层源码分析之------tp5.1类的自动加载机制
tp框架作为国内主流框架,目前已经发布了6.0版本,相当于3.*版本是进行了重构,今天我们从源码的角度来研究下tp5.1自动加载的实现 作为单入口框架,从入口文件看起,入口文件在public/下,那么 ...
- 彻底解决 Mechanism level: Failed to find any Kerberos tgt
错误描述 Secure Client Cannot Connect ([Caused by GSSException: No valid credentials provided(Mechanism ...
- Golang的安装和编译
一.下载安装(Ubuntu16.04) 1.下载地址:https://golang.google.cn/dl/ 2.下载Linux版本的安装包go1.10.3.linux-amd64.tar.gz并复 ...