Created
December 11, 2013 15:26
-
-
Save kuuso/7912346 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int hash(char *str); | |
char name_Note[12][3]={ "C","Cs","D","Ds","E","F","Fs","G","Gs","A","As","B" }; | |
int main(){ | |
unsigned short key_mask[12]; | |
char Note[3]; | |
unsigned short usedNote; | |
int T; | |
int N; | |
int i,j; | |
int i_t; | |
int cnt; | |
//各keyのavoid noteのbitに1 | |
key_mask[0]= (0x1<<0) | (0x1<<2) | (0x1<<4) | (0x1<<5) | (0x1<<7) | (0x1<<9) | (0x1<<11) ; | |
for(i=1;i<12;i++){ | |
key_mask[i]=(key_mask[i-1]<<1) | ((key_mask[i-1]&0x800)>>11); | |
} | |
for(i=0;i<12;i++){ | |
key_mask[i]=0x0FFF & ~key_mask[i]; | |
} | |
//あとはavoid noteを使っていないか12keysで調べるだけ。。。 | |
scanf("%d\n",&T); | |
for(i_t=0;i_t<T;i_t++){ | |
scanf("%d\n",&N); | |
usedNote=0; | |
for(i=0;i<N;i++){ | |
scanf("%s",Note); | |
usedNote=usedNote | 0x1<<hash(Note); | |
} | |
cnt=0; | |
for(i=0;i<12;i++){ | |
if(!(usedNote & key_mask[i])){ | |
cnt++; | |
printf(cnt==1?"%s":" %s",name_Note[i]); | |
} | |
} | |
if(!cnt)printf("invalid"); | |
printf("\n"); | |
} | |
return 0; | |
} | |
int hash(char *str){ | |
if(!strcmp(str,"C"))return 0; | |
if(!strcmp(str,"Cs"))return 1; | |
if(!strcmp(str,"D"))return 2; | |
if(!strcmp(str,"Ds"))return 3; | |
if(!strcmp(str,"E"))return 4; | |
if(!strcmp(str,"F"))return 5; | |
if(!strcmp(str,"Fs"))return 6; | |
if(!strcmp(str,"G"))return 7; | |
if(!strcmp(str,"Gs"))return 8; | |
if(!strcmp(str,"A"))return 9; | |
if(!strcmp(str,"As"))return 10; | |
if(!strcmp(str,"B"))return 11; | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment