返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         char ans;
  7.         re:
  8.         cout<<"請輸入a、b或c:";
  9.         cin>>ans;
  10.         switch(ans)
  11.         {
  12.                 case 'a':
  13.                         cout<<"你剛剛輸入的是a"<<endl;       
  14.                         break;
  15.                 case 'b':
  16.                         cout<<"你剛剛輸入的是b"<<endl;
  17.                         break;
  18.                 case 'c':
  19.                         cout<<"你剛剛輸入的是c"<<endl;
  20.                         break;
  21.                 default:
  22.                     cout<<"沒這個選項"<<endl;                       
  23.         }
  24.                 cout<<endl;
  25.                 goto re;
  26.                 system("pause");
  27.                 return 0;       
  28. }
  29.   
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         char ans;
  7.         re:
  8.         cout<<"請輸入a、b或c:";
  9.         cin>>ans;
  10.         switch(ans)
  11.         {
  12.                 case 'a':
  13.                         cout<<"你剛剛輸入的是a"<<endl;        
  14.                         break;
  15.                 case 'b':
  16.                         cout<<"你剛剛輸入的是b"<<endl;
  17.                         break;
  18.                 case 'c':
  19.                         cout<<"你剛剛輸入的是c"<<endl;
  20.                         break;
  21.                 default:
  22.                     cout<<"沒這個選項"<<endl;                        
  23.         }
  24.                 cout<<endl;
  25.                 goto re;
  26.                 system("pause");
  27.                 return 0;        
  28. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         char ans;
  7.         re:
  8.         cout<<"請輸入a、b或c:";
  9.         cin>>ans;
  10.         switch(ans)
  11.         {
  12.             case 'a':
  13.                     cout<<"你剛剛輸入的是a"<<endl;        
  14.                     break;
  15.             case 'b':
  16.                     cout<<"你剛剛輸入的是b"<<endl;
  17.                     break;
  18.             case 'c':
  19.                     cout<<"你剛剛輸入的是c"<<endl;
  20.                     break;
  21.             default:
  22.                 cout<<"沒這個選項"<<endl;                        
  23.         }
  24.         cout<<endl;
  25.         goto re;
  26.         system("pause");
  27.         return 0;        
  28. }
複製代碼

TOP

返回列表