题目链接:https://www.luogu.com.cn/problem/P5730
题目解析:
看了半天才明白题目是什么意思
下图样例中有10个红方框,每个红方框是一个数,依次是0,1,2,...,9
然后也没什么好方法,打表吧
1 #include <bits/stdc++.h> 2 using namespace std; 3 char a[110]; 4 int main() { 5 int n; 6 cin >> n; 7 string ans[10]; 8 for (int i = 1; i <= n; i++) { //读入n个字符 9 cin >> a[i]; 10 if (a[i] == '0') { 11 ans[1] += "XXX."; 12 ans[2] += "X.X."; 13 ans[3] += "X.X."; 14 ans[4] += "X.X."; 15 ans[5] += "XXX."; 16 } 17 if (a[i] == '1') { 18 ans[1] += "..X."; 19 ans[2] += "..X."; 20 ans[3] += "..X."; 21 ans[4] += "..X."; 22 ans[5] += "..X."; 23 } 24 if (a[i] == '2') { 25 ans[1] += "XXX."; 26 ans[2] += "..X."; 27 ans[3] += "XXX."; 28 ans[4] += "X..."; 29 ans[5] += "XXX."; 30 } 31 if (a[i] == '3') { 32 ans[1] += "XXX."; 33 ans[2] += "..X."; 34 ans[3] += "XXX."; 35 ans[4] += "..X."; 36 ans[5] += "XXX."; 37 } 38 if (a[i] == '4') { 39 ans[1] += "X.X."; 40 ans[2] += "X.X."; 41 ans[3] += "XXX."; 42 ans[4] += "..X."; 43 ans[5] += "..X."; 44 } 45 if (a[i] == '5') { 46 ans[1] += "XXX."; 47 ans[2] += "X..."; 48 ans[3] += "XXX."; 49 ans[4] += "..X."; 50 ans[5] += "XXX."; 51 } 52 if (a[i] == '6') { 53 ans[1] += "XXX."; 54 ans[2] += "X..."; 55 ans[3] += "XXX."; 56 ans[4] += "X.X."; 57 ans[5] += "XXX."; 58 } 59 if (a[i] == '7') { 60 ans[1] += "XXX."; 61 ans[2] += "..X."; 62 ans[3] += "..X."; 63 ans[4] += "..X."; 64 ans[5] += "..X."; 65 } 66 if (a[i] == '8') { 67 ans[1] += "XXX."; 68 ans[2] += "X.X."; 69 ans[3] += "XXX."; 70 ans[4] += "X.X."; 71 ans[5] += "XXX."; 72 } 73 if (a[i] == '9') { 74 ans[1] += "XXX."; 75 ans[2] += "X.X."; 76 ans[3] += "XXX."; 77 ans[4] += "..X."; 78 ans[5] += "XXX."; 79 } 80 } 81 for (int i = 1; i <= 5; i++) { 82 ans[i] = ans[i].substr(0, ans[i].length() - 1); //去除最后一列点 83 cout << ans[i] << endl; 84 } 85 return 0; 86 }