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 Permalink 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之前有01234所以共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;
}
//最后一个问题,我们不能一个个的打印数字,这样就会造成数字不是横向排列,成了竖的!
//所以,我们需要按 “行-数字-列”这样三层循环的方式打印!
//说白了就是第一行的话我们要输出12345..的第一行内容,共三列,
// 换行后再输出12345..的第二行内容,共三列,以此类推。
*/
return 0;
}