返回列表 發帖

[練習]小星星 2

本帖最後由 陳品肇 於 2021-10-30 11:35 編輯


方法一:
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.     // alt+41401 ★ 41400☆  
  8.     // 垂直方向
  9.     for(int i=5;i>=1;i--)
  10.     {
  11.       // 橫軸的方向
  12.       for(int j=1;j<=i;j++)
  13.       {
  14.         cout<<"*";
  15.       }
  16.       cout<<endl;
  17.     }
  18.     system("pause");
  19.     return 0;   
  20. }
複製代碼
方法二:
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     // 垂直方向
  7.     for(int i=1;i<=5;i++)
  8.     {
  9.       // 橫軸的方向
  10.       for(int j=5;j>=i;j--)
  11.       {
  12.         cout<<"*";
  13.       }
  14.       cout<<endl;
  15.     }
  16.     system("pause");
  17.     return 0;   
  18. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

返回列表