返回列表 發帖
本帖最後由 t2364705 於 2011-9-17 16:30 編輯
  1. #include <iostream>

  2. using namespace std;

  3. int main()

  4. {

  5.    
  6.     float x, y, z;
  7.     cout<<"請輸入上底(公分)"<<endl;

  8.     cin>>x;

  9.     cout<<"請輸入下底(公分)"<<endl;
  10.    
  11.     cin>>y;
  12.    
  13.     cout<<"請輸入高(公分)"<<endl;
  14.    
  15.     cin>>z;
  16.    
  17.     cout<<"梯形面積為"<<x+y*z/2<<"平方公分"<<endl;
  18.      
  19. system("pause");

  20.   return 0;   

  21. }
複製代碼

TOP

  1. #include <iostream>   //呼叫函數庫
  2. using namespace std;
  3. int main()
  4. {
  5.      int score;  //宣告一個名為score的整數變數
  6.      cout<<"請輸入你的分數";
  7.      cin>>score;
  8.      if(score>=60)  //如果成績高於或低於60分
  9. {
  10.      cout<<"恭喜你!及格了!";
  11. }
  12. else     //否則
  13. {
  14.          cout<<"哎呀!不及格!請再努力!:";
  15. }
  16. cout<<endl;     
  17. system("pause");

  18.   return 0;   

  19. }
複製代碼

TOP

  1. #include <iostream>  //呼叫函數庫
  2. using namespace std;
  3. int main()
  4. {
  5.      int age;  //宣告一個名為age的整數變數
  6.      cout<<"輸入您的年齡";
  7.      cin>>age;
  8.      if(age>=18)  //如果年齡高於或低於100歲
  9. {
  10.      cout<<"恭喜你!你可以考騎機車駕照了!";
  11. }
  12. else     //否則
  13. {
  14.          cout<<"哎呀!你不行!你的年齡還沒到:";
  15. }
  16. cout<<endl;     
  17. system("pause");

  18.   return 0;   

  19. }
複製代碼

TOP

返回列表