-
Notifications
You must be signed in to change notification settings - Fork 0
/
P4732.cpp
55 lines (45 loc) · 1.12 KB
/
P4732.cpp
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
#include <iostream>
#include <string>
using namespace std;
string music[12] = {"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"};
int get_index(string s) {
if (s == "Bb") {
return 1;
}
if (s == "B#") {
return 3;
}
if (s == "Fb") {
return 7;
}
for (int i = 0; i < 12; i++) {
if (music[i] == s) {
return i;
}
}
return 0;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
while (1) {
string str[4];
int n;
cin >> str[0];
if (str[0] == "***") break;
cin >> str[1] >> str[2] >> str[3] >> n;
for (int i = 0; i < 4; i++) {
if (str[i] == "G#" && n == 1) cout << "A ";
else if (str[i] == "A" && n == -1) cout << "G# ";
else if (str[i] == "Db" && n == 1) cout << "D ";
else if (str[i] == "E#" && n == -1) cout << "E ";
else {
int idx = get_index(str[i]);
cout << music[idx + n] << " ";
}
}
cout << "\n";
}
return 0;
}