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 ...
随机推荐
- PHP 利用闭包偷窥马对人类的想法
<?php /** * reference:http://www.php.net/manual/en/reflectionmethod.getclosure.php * Learn this a ...
- [网络流 24 题] luoguP4016 负载平衡问题
[返回网络流 24 题索引] 题目描述 有成环状的 nnn 堆纸牌,现将一张纸牌移动到其邻堆称为一次操作.求使得所有堆纸牌数相等的最少移动次数. Solution 4016\text{Solution ...
- date命令查看与修改
在我们使用linux服务器时,肯定会遇到Linux服务器时间不准确的情况如何查看Linux系统的时间,如何修改Linux系统上的当前时间呢. 查看Linux系统当前时间: 命令: date +回车 修 ...
- oracle中创建用户、角色、权限简单使用
Oracle关于用户.权限.角色简单使用 创建数据库用户(在system用户下)create user 用户名 identified by 密码; 授权grant 权限名 to 用户名; 查看当前用户 ...
- VMware安装和linux(centos7)系统安装
下载centos系统ISO镜像 安装linux系统和winsdows安装系统一样,需要系统文件.浏览器访问centos官网进行下载,http://www.centos.org,因为是国外网站所有下载速 ...
- 百万年薪python之路 -- 并发编程之 多进程 一
并发编程之 多进程 一. multiprocessing模块介绍 python中的多线程无法利用多核优势,如果想要充分地使用多核CPU的资源(os.cpu_count()查看),在python中大 ...
- Activity 学习(一) 插件安装篇
目录 Ider下安装 Eclipse下安装 Ider安装图解 首先,创建一个普通的Java工程即可,然后按照下面流程进行: 1:点击菜单中的File(最左上角),选择settings 2:plugin ...
- django-模板之URL标签(五)
book/views.py from django.shortcuts import render def index(request): return render(request,"in ...
- BOOL,int,float,指针变量 与“零值”比较的if语句
分别给出BOOL,int,float,指针变量 与“零值”比较的 if 语句(假设变量名为var) 解答: BOOL型变量:if(!var) int型变量: if(var==0) float型变量: ...
- 设计模式C++描述----17.备忘录(Memento)模式
一. 备忘录模式 定义:在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态.这样以后就可将该对象恢复到原先保存的状态. 结构图: 使用范围: Memento 模式比较适用于功能 ...