返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int start,end,a,b;
  7.     char a;
  8.     re:
  9.     cout<<"1ascii轉字母 2字母轉ascii 3結束"<<endl;;
  10.     cin>>start;
  11.     switch(start)
  12.     {
  13.         case 1:
  14.              cout<<"請輸入ASCII碼: ";
  15.              cin>>end;
  16.              cout<<"字元為: "<<char(end);
  17.              break;
  18.         case 2:
  19.              cout<<"請輸入字元: ";
  20.              cin>>a;
  21.              cout<<"ASCII為: "<<int(a);
  22.              break;
  23.         case 3:
  24.              goto end;
  25.              break;  
  26.         default:
  27.              cout<<"輸入錯誤"<<endl;                              
  28.     }
  29.     cout<<endl;
  30.     goto re:
  31.     end:
  32.         
  33.     system("pause");   
  34.     return 0;
  35. }
複製代碼

TOP

返回列表