#include <iostream>
using namespace std;
int main() {
for(int i = 1; i <= 10; i++) {
for(int j = 1; j <= i; j++)
cout << '*';
for(int j = 9; j >= i; j--)
cout << ' ';
for(int j = 10; j >= i; j--)
cout << '*';
for(int j = 1; j < i; j++)
cout << " ";
for(int j = 10; j >= i; j--)
cout << '*';
for(int j = 9; j >= i; j--)
cout << ' ';
for(int j = 1; j <= i; j++)
cout << '*';
cout << endl;
}
return 0;
}
C++大学教程(第九版) 第5章练习题 5.12 使用嵌套的for循环绘制图案——选做题
最新推荐文章于 2023-07-21 02:09:42 发布