#1174. 打印图形
打印图形
当前没有测试数据。
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
/*
0000*
000**
00***
0****
*****
*/
cin >> n;
// for (int i = 1; i <= n; i++) { // 行
// // 空格
// for (int j = 1; j <= n - i; j++) {
// cout << " ";
// }
//
// // 星星
// for (int j = 1; j <= i; j++) {
// cout << "*";
// }
// cout << endl;
// }
//
/*
*0000
**000
***00
****0
*****
*/
// for (int i = 1; i <= n; i++) { // 行
// // 星星
// for (int j = 1; j <= i; j++) {
// cout << "*";
// }
//
// // 空格
// for (int j = 1; j <= n - i; j++) {
// cout << " ";
// }
// cout << endl;
// }
/*
000*000
00***00
0*****0
*******
*/
// for (int i = 1; i <= n; i++) { // 行
// // 空格
// for (int j = 1; j <= n - i; j++) {
// cout << " ";
// }
//
// // 星星
// for (int j = 1; j <= 2 * i - 1; j++) {
// cout << "*";
// }
//
//
// cout << endl;
// }
//
/*
*******
0*****0
00***00
000*000
*/
for (int i = 1; i <= n; i++) { // 行
// 空格
for (int j = 1; j <= i - 1; j++) {
cout << " ";
}
// 星星
for (int j = 1; j <= 2 * (n - i) + 1; j++) {
cout << "*";
}
cout << endl;
}
/*
000*000
00***00
0*****0
*******
0*****0
00***00
000*000
*/
/*
*******
0*****0
00***00
000*000
00***00
0*****0
*******
*/
return 0;
}