返回列表 發帖

if...else 判斷式

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     int score;
  8.     cout<<"請輸入你的成績: ";
  9.     cin>>score;
  10.     if(score>=60)
  11.     {
  12.         cout<<"恭喜你及格了,給你糖吃!"<<endl;
  13.     }else
  14.     {
  15.         cout<<"不及格!打屁股!"<<endl;
  16.     }
  17.     goto re;
  18.     system("pause");
  19.     return 0;   
  20. }
複製代碼

  1. //if...else
  2. #include<iostream>
  3. #include<cstdlib>
  4. using namespace std;
  5. int main()
  6. {
  7.     int score;
  8.     cout<<"請輸入你的成績:";
  9.     cin>>score;
  10.     if(score>=60)
  11.     {
  12.     cout<<"你及格了"<<endl;            
  13.     }else
  14.     {
  15.     cout<<"不及格"<<endl;
  16.     }
  17.     system("pause");
  18.     return 0;
  19. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     int score;
  8.     cout<<"請輸入你的成績: ";
  9.     cin>>score;
  10.     if(score>=60)
  11.     {
  12.         cout<<"恭喜你及格了,給你糖吃!"<<endl;
  13.     }else
  14.     {
  15.         cout<<"不及格!打屁股!"<<endl;
  16.     }
  17.     goto re;
  18.     system("pause");
  19.     return 0;   
  20. }
複製代碼
我是眾神之王XXX  I love you
0000000000

TOP

  1. #include<cstdlib>
  2. #include<iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.    int score;
  7.    cout<<"請輸入您的成績";
  8.    cin>>score;
  9.    if(score>=60)
  10.    {
  11.       cout<<"阿不就好棒棒"<<endl;
  12.    }  
  13.    else
  14.    {
  15.       cout<<"遜掉了拉"<<endl;
  16.       
  17.    }
  18.      
  19.      system("pause");
  20.      return 0;
  21. }
  22.    
複製代碼

TOP

  1. #include<iostream>  //引入標頭檔 <基本輸入輸出> in & out stream
  2. #include<cstdlib>   //引入標頭檔 <基本函式庫> c standard library
  3. using namespace std;  //使用命名空間 std
  4. int main() //主函式
  5. {
  6.     re:
  7.     int x;
  8.     cout<<"輸入成績:"<<endl;
  9.     cin>>x;
  10.     if (x>=60)
  11.     {
  12.              cout<<"你好棒"<<endl;
  13.     }
  14.     else
  15.     {
  16.          cout<<"去罰站"<<endl;  
  17.     }
  18.    
  19.     system("pause");  //暫停
  20.     return 0;         //回傳0到主控台告訴電腦,程式已成功執行
  21. }
複製代碼

TOP

返回列表