Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

第五十题水过~~贴代码~~

Posted by shmr0077 at 2011-05-01 20:23:41 on Problem 2326
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;

char tones[12][3]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};

int main(){
	//freopen("in.txt","r",stdin);
	
	char c[3],line[1001];
	int i,j,k,t,count;
	bool major_scale[12][12],key[12];
	memset(major_scale,0,sizeof(major_scale));
	for(i=0;i<12;i++){
		for(j=i,t=0;t<8;t++){
			major_scale[i][j]=1;
			if(t==2 || t==6)j=(j+1)%12;
			else j=(j+2)%12;
		}
	}
	while(gets(line) && strcmp(line,"END")){
		memset(key,0,sizeof(key));
		count=12;
		for(i=0;line[i]!='\0';i++){
			for(j=0;line[i]!=' ' && line[i]!='\0';i++,j++)c[j]=line[i];
			c[j]='\0';
			if(line[i]=='\0')i--;
			for(j=0;j<12;j++){
				if(key[j])continue;
				else{
					for(k=0;strcmp(c,tones[k]);k++);
					if(!major_scale[j][k]){
						key[j]=1;count--;
					}
				}
			}
			if(count==0)break;
		}
		if(count==0)printf("\n");
		else{
			for(i=0,j=0;i<12;i++){
				if(!key[i]){
					printf("%s",tones[i]);
					if(++j!=count)printf(" ");					
				}
			}
			printf("\n");
		}
	}
	
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator