-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMusicalScales.cpp
More file actions
86 lines (63 loc) · 1.15 KB
/
MusicalScales.cpp
File metadata and controls
86 lines (63 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <string>
using namespace std;
const int NOTES = 12;
const int TONES = 8;
const int MAX_N = 100;
int n;
const string ALL[NOTES * 3] = {"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"};
int order[TONES + 2] = {0, 1, 2, 2, 3, 4, 5, 5};
string scale[NOTES][TONES];
string notes[MAX_N];
void genScale()
{
for(int i = 0; i < NOTES; i++)
{
for(int j = 0; j < TONES; j++)
{
scale[i][j] = ALL[i + j + order[j]];
}
}
}
bool check(int cur)
{
bool printed = true;
for(int i = 0; i < n; i++)
{
bool found = false;
for(int j = 0; j < TONES; j++)
{
if(scale[cur][j] == notes[i])
{
found = true;
}
}
printed = (found && printed);
}
return printed;
}
int main()
{
genScale();
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> notes[i];
}
bool printed = false;
for(int i = 0; i < NOTES; i++)
{
if(check(i))
{
if(printed) cout << " ";
printed = true;
cout << ALL[i];
}
}
if(!printed)
{
cout << "none";
}
cout << endl;
return 0;
}