本帖最後由 陳曜誌 於 2024-7-20 15:23 編輯
- #include<iostream>
- using namespace std;
- int main()
- {
- int i,j,k;
- for(int i=5; i>=1; i--) //i=1 2 3 4 5
- {
- for(int j=1; j<=(5-i); j++) // i=1 j=4
- {
- cout<<" ";
- }
- for(int j=1; j<=(2*i-1); j++) //k=1
- {
- cout<<"*";
- }
- // for(int j=0; j<=(5-i); j++) // i=1 j=4
- // {
- // cout<<" ";
- // }
- cout<<endl;
- }
- }
- /*
- i = 5 4 3 2 1
- space = 0 1 2 3 4
- star = 9 7 5 3 1
- ttps://www.youtube.com/watch?v=754dbjx5xIw
- */
複製代碼 |