题目传送门:P5725 【深基4.习8】求三角形 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
看完这道题我绝望了,题解没一个让我看得懂的【因为我是一个XXS(你懂的)】 ,最可气的是他们根本不能打印出正确的三角形(气)!
所以,
AC代码:
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int num = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++){
if (num < 10) {
cout << '0';
}
cout << num;
}
cout << endl;
}
num = 1;
int now = n - 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (j <= now) {
cout << " ";
} else {
if (num < 10) {
cout << '0';
}
cout << num;
}
}
now--;
cout << endl;
}
return 0;
}
本蒟蒻第三篇博客,各位大神多多点赞支持,Please~(如果有什么代码上的问题请各位大神发到讨论区,谢谢~)BYEBYE~
对了,
其他两篇博客传送门:
1.计蒜客《迷宫询问》题解-优快云博客
2.PCL2启动器在哪里下载?(附保姆级教程)_pcl2启动器龙腾猫跃-优快云博客
有兴趣的各位朋友记得捧个场呦~