返回列表 發帖

if...else 判斷式

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int score;
  7.     cout<<"請輸入你的分數: ";
  8.     cin>>score;
  9.     if(score>=60)
  10.         cout<<"恭喜你及格了!"<<endl;
  11.     else
  12.         cout<<"不及格!請再努力!"<<endl;
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼

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

TOP

  1. #include <iostream>
  2. #include <cstdlib>
  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.    system("pause");
  18.    return 0;
  19. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int rape;
  7.     cout<<"請輸入你的分數: ";
  8.     cin>>rape;
  9.     if(rape>=60)
  10.         cout<<"你ok!"<<endl;
  11.     else
  12.         cout<<"不及格>_<"<<endl;
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int r;
  7.     cout<<"請輸分數: ";
  8.     cin>>r;
  9.     if(score>=60)
  10.         cout<<"及格"<<endl;
  11.     else
  12.         cout<<"不及格"<<endl;
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼
http://fs-old.mis.kuas.edu.tw/~s1102137106/music/

TOP

返回列表