栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 1924 Major Scales

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 1924 Major Scales

#include <map>#include <string>#include <sstream>#include <iostream>using namespace std;#define VALUE(i) make_pair(pstr[i], i)const char *const pstr[12] = {    "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};const map<string, int>::value_type mps[12] = {    VALUE(0), VALUE(1), VALUE(2), VALUE(3), VALUE(4), VALUE(5),    VALUE(6), VALUE(7), VALUE(8), VALUE(9), VALUE(10), VALUE(11)};const map<string, int> mp(mps, mps + 12);const int bin[12] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048};const int off[8] = {0, 2, 4, 5, 7, 9, 11, 12};int mask[12];void init(){    for (int i = 0; i < 12; i++) {        mask[i] = 0;        for (int j = 0; j < 8; j++) mask[i] |= bin[(i + off[j]) % 12];    }}int main(void){    bool blank;    string buf;    init();    while(getline(cin, buf) && buf != "END") {        istringstream iss(buf);        int s = 0;        while(iss >> buf) s |= bin[mp.find(buf)->second];        blank = false;        for (int i = 0; i < 12; i++) { if((mask[i] | s) == mask[i]) {     if(blank)         cout << " ";     else         blank = true;     cout << pstr[i]; }        }        cout << endl;    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/376151.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号