返回列表 發帖
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int answer;     
  6. cout<<"請問現在台灣第一任總統是誰?"<<endl;
  7. cout<<"(1)李登輝(2)莫那魯道(3)馬英九(4)勇者巴萊"<<endl;   
  8. cout<<"請作答...";   
  9. cin>>answer;   
  10. cout<<endl;   
  11. switch(answer)   
  12. {
  13. case 1:
  14.        cout<<"答對了!!";
  15.        break;
  16. case 2:
  17.        cout<<"是原住民ㄜ!!";
  18.        break;
  19. case 3:
  20.        cout<<"這是現在的總統!!";
  21.        break;
  22. case 4:
  23.        cout<<"還沉迷於新電影:賽德克巴萊ㄚ!!";
  24.        break;
  25. default:
  26.        cout<<"你來亂的喔!";
  27. }   
  28. cout<<endl;   
  29. system("pause");   
  30. return 0;      
  31. }
複製代碼

TOP

  1. #include<iostream>

  2. using namespace std;

  3. int main()

  4. {

  5.    int answer;

  6.    cout<<"請問現在台灣第一任總統是誰?"<<endl;

  7.    cout<<"1)李登輝(2)莫那魯道(3)馬英九(4)勇者巴萊"<<endl;

  8.    cin>>answer;

  9.    if(answer==1)

  10.    {

  11.        cout<< "答對了!!"<<endl;

  12.    }

  13.    else if(answer==2)

  14.    {

  15.        cout<< "是原住民ㄜ!! "<<endl;         

  16.    }

  17.    else if(answer==3)

  18.    {

  19.        cout<< "這是現在的總統!!"<<endl;

  20.    }

  21.    else if(answer==4)

  22.    {

  23.        cout<< "還沉迷於新電影:賽德克巴萊ㄚ!"<<endl;         

  24.    }

  25.   
  26.    else

  27.    {

  28.        cout<<"你來亂的喔!"<<endl;

  29.    }

  30.    system("pause");

  31.    return 0;

  32. }
複製代碼

TOP

返回列表