返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     char a;
  7.     cout<<"請問你是誰?  (A)你 (B)他 (C)她 (D)我 ";
  8.     cout<<"答案=";
  9.     cin>>a;
  10.     switch(a)
  11.     {         
  12.               case 'A':
  13.               case 'a':
  14.               case 'B':
  15.               case 'b':
  16.               case 'C':
  17.               case 'c':
  18.                     cout<<"錯了"<<endl;
  19.                     break;
  20.               case 'D':
  21.               case 'd':
  22.                     cout<<"對了"<<endl;
  23.                     break;
  24.               default:
  25.                       cout<<"輸入錯誤"<<endl;
  26.                       break;
  27.     }   
  28.     system("pause");
  29.     return 0;
  30. }
複製代碼

TOP

返回列表