ZOJ-1274
来源:互联网 发布:小米生活和淘宝的关系 编辑:程序博客网 时间:2024/06/13 12:08
没啥难度的模拟题,按规则写就是了
#include<iostream>#include<map>#include<cstring>#include<cctype>#include<cstdio>using namespace std;int main(){string S[] = { "A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G","G#" };map<string, int> M;for (int i = 0; i < 12; i++)M[S[i]] = i;M["Bb"] = 1;M["Db"] = 4;M["Eb"] = 6;M["Gb"] = 9;M["Ab"] = 11;bool flag[12];string s[3], temp;while (cin >> s[0] >> s[1] >> s[2]){memset(flag, 0, sizeof(flag));for (int i = 0; i < 3; i++){temp = s[i];if (islower(s[i][0]))temp[0] = temp[0] - 'a' + 'A';flag[M[temp]] = true;}bool major = false, minor = false;int i;for (i = 0; i < 12; i++)if (flag[i]){int mid1 = (i + 4) % 12;int mid2 = (i + 3) % 12;int end = (i + 7) % 12;if (flag[mid1] && flag[end]){major = true;break;}if (flag[mid2] && flag[end]){minor = true;break;}}if (major)printf("%s %s %s is a %s Major chord.\n", s[0].c_str(),s[1].c_str(), s[2].c_str(), S[i].c_str());else if (minor)printf("%s %s %s is a %s Minor chord.\n", s[0].c_str(),s[1].c_str(), s[2].c_str(), S[i].c_str());elseprintf("%s %s %s is unrecognized.\n", s[0].c_str(), s[1].c_str(),s[2].c_str());}return 0;}
0 0
- ZOJ-1274
- 水题几枚zoj 1195 zoj 2421 zoj 2405 zoj 2835 zoj 1274
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- 解决拍照按钮为英文问题
- hdu 1828 Picture 线段树+离散化(其区间的个数)
- mininet+FlowVisor+OpenDayLight环境搭建及实验一
- CodeBlocks的常用快捷键
- 【辗转相除法求最大公约数】
- ZOJ-1274
- hdu 1011 Starship Troopers(树形动态规划)
- hdu 3657最大点权独立集变形(方格取数变形)
- poj 2155 Matrix (二维树状数组)
- 让你提前认识软件开发(44):如何解决软件故障?
- 【Eclipse】推荐UML插件Green UML、AmaterasUML
- 我买网B轮融资成功,五周年豪掷千万回馈会员
- uva10911 - Forming Quiz Teams(记忆化搜索)
- maven入门