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

TOP

返回列表