Files
python/TangDou/LuoGuBook/P5730_2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

48 lines
1.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
string a[5] =
{"XXX...X.XXX.XXX.X.X.XXX.XXX.XXX.XXX.XXX",
"X.X...X...X...X.X.X.X...X.....X.X.X.X.X",
"X.X...X.XXX.XXX.XXX.XXX.XXX...X.XXX.XXX",
"X.X...X.X.....X...X...X.X.X...X.X.X...X",
"XXX...X.XXX.XXX...X.XXX.XXX...X.XXX.XXX"
};
int main() {
//子任务1:打印数字0
for (int i = 0; i <= 4; i++) {
for (int j = 0; j < 3; j++)
cout << a[i][j];
cout << endl;
}
//子任务2:打印数字1
for (int i = 0; i <= 4; i++) {
for (int j = 4; j <= 6; j++)
cout << a[i][j];
cout << endl;
}
//子任务3:打印数字2
for (int i = 0; i <= 4; i++) {
for (int j = 36; j < 36 + 3; j++)
cout << a[i][j];
cout << endl;
}/*
//小结:如果打印数字x,首先需要知道它对应的数字值是几,比如'5',我们需要数字5
//'5'-'0'=5
//有了5以后,就是一个数字四个宽度,5之前有0,1,2,3,4,所以共5个,5*4=20
//数字5就是从20开始,来三个,然后添加一个.
for (int i = 0; i <= 4; i++) {
for (int j = 20; j < 20 + 3; j++)
cout << a[i][j];
cout << endl;
}
//最后一个问题,我们不能一个个的打印数字,这样就会造成数字不是横向排列,成了竖的!
//所以,我们需要按 “行-数字-列”这样三层循环的方式打印!
//说白了就是,第一行的话,我们要输出1,2,3,4,5..的第一行内容,共三列,
// 换行后再输出1,2,3,4,5..的第二行内容,共三列,以此类推。
*/
return 0;
}