#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循環繪製圖案——選做題
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.