返回列表 發帖
本帖最後由 陳品諺 於 2023-6-25 23:48 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a, b;
  7.         cout<<"請輸入兩個數字,分別為梯形的上底及高(公分): ";
  8.         cin>>a>>b;
  9.         cout<<"面積為: "<<(a+a+(b-1)*2)*b/2<<endl;
  10.         cout<<endl<<endl;
  11.         for(int i=0;i<b;i++)
  12.     {
  13.             for(int j=i;j<b;j++)
  14.             {
  15.                         cout<<" ";
  16.                 }
  17.                 for(int j=i;j<a+i+i*2;j++)
  18.                 {
  19.                     cout<<"*";
  20.                 }
  21.                 cout<<endl;
  22.         }
  23.         system("pause");
  24.         return 0;
  25. }
複製代碼

TOP

返回列表