題目連結: https://zerojudge.tw/ShowProblem?problemid=e283
# 解題思路
先將題目的二元序全轉換為十進位存起來,每當輸入一個序列時,再將其轉換為十進位,輸出其對應的字元就好啦
# 程式碼
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int n; | |
while (cin >> n){ | |
char letter[16]; | |
memset(letter, '\0', sizeof(letter)); | |
letter[5] = 'A'; | |
letter[7] = 'B'; | |
letter[2] = 'C'; | |
letter[13] = 'D'; | |
letter[8] = 'E'; | |
letter[12] = 'F'; | |
for (int i=0; i<n; i++){ | |
int x = 0, tmp; | |
for (int j=0; j<4; j++){ | |
cin >> tmp; | |
x = 2 * x + tmp; | |
} | |
cout << letter[x]; | |
} | |
cout << '\n'; | |
} | |
return 0; | |
} |