검색결과 리스트
글
C++ 기본서를 배우고 만들어 본 프로그램이다.
음악 코드를 외우기 위한 프로그램이다.
일단은 근음이 C인 코드만 적었다.
코드의 구성음은 영어 대문자로 입력해야 한다.
Dev-C++로 만들었다.
#include <iostream>
using namespace std;
class Chord
{
public:
char name[9];
char notes[13];
Chord(char *name, char *notes);
Chord(){}
void setName(char *name);
void setNotes(char *notes);
};
void Chord::setName(char *name)
{
strcpy(this->name, name);
}
void Chord::setNotes(char *notes)
{
strcpy(this->notes, notes);
}
Chord::Chord(char *name, char *notes)
{
setName(name);
setNotes(notes);
}
int main()
{
int i=0, t=1, k=0;
char answer[20];
Chord C[16];
C[0].setName("C");
C[0].setNotes("CEG");
C[1].setName("Cm");
C[1].setNotes("CEbG");
C[2].setName("C7");
C[2].setNotes("CEGBb");
C[3].setName("CM7");
C[3].setNotes("CEGB");
C[4].setName("Cm7");
C[4].setNotes("CEbGBb");
C[5].setName("CmM7");
C[5].setNotes("CEbGB");
C[6].setName("Cm7-5");
C[6].setNotes("CEbGbBb");
C[7].setName("Cdim");
C[7].setNotes("CEbGbA");
C[8].setName("Csus4");
C[8].setNotes("CFG");
C[9].setName("Caug");
C[9].setNotes("CEG#");
C[10].setName("Cadd2");
C[10].setNotes("CDEG");
C[11].setName("Cadd9");
C[11].setNotes("CEGD");
C[12].setName("C6");
C[12].setNotes("CEGA");
C[13].setName("C9");
C[13].setNotes("CEGBbD");
C[14].setName("C11");
C[14].setNotes("CEGBbDF");
C[15].setName("C13");
C[15].setNotes("CEGBbDFA");
while(t==1)
{
int count=0;
cout<<"Enter "<<C[k].name<<" notes : ";
cin>>answer;
if(strlen(C[k].notes)!=strlen(answer))
{
cout<<"<X>"<<endl;
break;
}
for(i=0; i<strlen(C[k].notes); i++)
{
if(C[k].notes[i]==answer[i])
{
count++;
}
}
if(strlen(C[k].notes)==count)
{
t=1;
k++;
cout<<"<O>"<<endl;
if(k==16)
{
cout<<"Congratulations! You have solved all the questions correctly."<<endl;
break;
}
}
else
{
cout<<"<X>"<<endl;
t=0;
}
}
system("PAUSE");
}
RECENT COMMENT