返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;

  4.    
  5.    

  6. int area()
  7. {
  8.      int a, b;
  9.      cout<<"請輸入底:";
  10.      cin>>a;
  11.      cout<<"\n請輸入高:";
  12.      cin>>b;
  13.      return a*b/2;
  14.         
  15. }
  16. int main()
  17. {
  18.     bool run=true;
  19.     string con;
  20.     while(run)
  21.     {
  22.          cout<<"\n此三角形面積為:"<<area()<<endl;
  23.          cout<<"想繼續請打1:";
  24.          cin>>con;
  25.          if(con!="1")
  26.          {
  27.               run = false;
  28.          }
  29.     }
  30.     system("pause");
  31.     return 0;
  32. }   
複製代碼

TOP

返回列表