SZRKDSZ @ 2023-11-14 16:56:04
#include<iostream>
using namespace std;
int put[5][400] = {0};
int n = 0, point[5] = {0};
void pd(int start_y,int a1,int a2,int a3,int a4,int a5) {
put[0][start_y] = { a1 };
put[1][start_y] = { a2 };
put[2][start_y] = { a3 };
put[3][start_y] = { a4 };
put[4][start_y] = { a5 };
}
void num(int start_y,int nums) {
switch (nums) {
case 0:for (int i = 0; i < 5; i++) { put[i][start_y] = { 1 }; }
put[0][start_y + 1] = { 1 }; put[4][start_y + 1] = { 1 };
for (int i = 0; i < 5; i++) { put[i][start_y + 2] = { 1 }; }
break;
case 1:
for (int i = 0; i < 5; i++) { put[i][start_y + 2] = { 1 }; }break;
case 2:
pd(start_y, 1, 0, 1, 1, 1);
pd(start_y+1, 1, 0, 1, 0, 1);
pd(start_y+2, 1, 1, 1, 0, 1); break;
case 3:
pd(start_y, 1, 0, 1, 0, 1);
pd(start_y + 1, 1, 0, 1, 0, 1);
pd(start_y + 2, 1, 1, 1, 1, 1); break;
case 4:
pd(start_y, 1, 1, 1, 0, 0);
pd(start_y + 1, 0, 0, 1, 0, 0);
pd(start_y + 2, 1, 1, 1, 1, 1); break;
case 5:
pd(start_y, 1, 1, 1, 0, 1);
pd(start_y + 1, 1, 0, 1, 0, 1);
pd(start_y + 2, 1, 0, 1, 1, 1); break;
case 6:
pd(start_y, 1, 1, 1, 1, 1);
pd(start_y + 1, 1, 0, 1, 0, 1);
pd(start_y + 2, 1, 0, 1, 1, 1); break;
case 7:
pd(start_y, 1, 0, 0, 0, 0);
pd(start_y + 1, 1, 0, 0, 0, 0);
pd(start_y + 2, 1, 1, 1, 1, 1); break;
case 8:
pd(start_y, 1, 1, 1, 1, 1);
pd(start_y + 1, 1, 0, 1, 0, 1);
pd(start_y + 2, 1, 1, 1, 1, 1); break;
case 9:
pd(start_y, 1, 1, 1, 0, 1);
pd(start_y + 1, 1, 0, 1, 0, 1);
pd(start_y + 2, 1, 1, 1, 1, 1); break;
}
}
int main() {
cin >> n;
int nums,* p;
p = new int[n];
cin >> nums;
for (int i = 0; i < n; i++) {
p[n - 1 - i] = { nums % 10 };
nums = nums / 10;
}
for (int i = 0; i < n; i++) {
num(4*i,p[i]);
}
for (int a = 0; a < 5; a++) {
for (int i = 0; i < (4 * n)-1; i++) {
if (put[a][i] == 1) { cout << 'X'; }
else { cout << '.'; }
}
cout << endl;
}
}
by Tom2 @ 2024-07-04 22:00:06
@SZRKDSZ 浅浅问一句,pd和num有啥用? 不多说了,上代码,记得关注:```c
using namespace std;
string num;
void ifcout1(char x){ if(x == '0' || x == '2' || x == '3' || x == '5' || x == '6' || x == '7' || x == '8' || x == '9'){ cout << "XXX"; } if(x == '1'){ cout << "..X"; } if(x == '4'){ cout << "X.X"; } } void ifcout2(char x){ if(x == '0' || x == '4' || x == '8' || x == '9'){ cout << "X.X"; } if(x == '1' || x == '2' || x == '3' || x == '7'){ cout << "..X"; } if(x == '5' || x == '6'){ cout << "X.."; } } void ifcout3(char x){ if(x == '0'){ cout << "X.X"; } if(x == '1' || x == '7'){ cout << "..X"; } if(x == '2' || x == '3' || x == '4'|| x == '5' || x == '6' || x == '8' || x == '9'){ cout << "XXX"; } } void ifcout4(char x){ if(x == '0' || x == '6' || x == '8'){ cout << "X.X"; } if(x == '1' || x == '7' || x == '9'){ cout << "..X"; } if(x == '2'){ cout << "X.."; } if(x == '3' || x == '4' || x == '5'){ cout << "..X"; } } void ifcout5(char x){ if(x == '0' || x == '2' || x == '3' || x == '5' || x == '6' || x == '8' || x == '9'){ cout << "XXX"; } if(x == '1' || x == '4' || x == '7'){ cout << "..X"; } }
int main(){ int n; cin >> n; cin >> num; for(int i = 0;i < n - 1;i++){ ifcout1(num[i]); cout << "."; } ifcout1(num[n - 1]); cout << endl; for(int i = 0;i < n - 1;i++){ ifcout2(num[i]); cout << "."; } ifcout2(num[n - 1]); cout << endl; for(int i = 0;i < n - 1;i++){ ifcout3(num[i]); cout << "."; } ifcout3(num[n - 1]); cout << endl; for(int i = 0;i < n - 1;i++){ ifcout4(num[i]); cout << "."; } ifcout4(num[n - 1]); cout << endl; for(int i = 0;i < n - 1;i++){ ifcout5(num[i]); cout << "."; } ifcout5(num[n - 1]); return 0; }