- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int ascii, option;
- char letter;
- start:
- cout<<"1-請輸入ASCCII碼查詢字元 2-輸入字元查詢ASCCI碼 3-結束程式"<<endl;
- cout<<"請選擇";
- cin>>option;
- switch(option)
- {
- case 1:
- cout<<"在此說入ASCII碼"<<endl;
- cin>>ascii;
- cout<<"ASCII碼"<<ascii<<"所對應的字元為"<<char(ascii);
- break;
-
- case 2:
- cout<<"在此輸入字元"<<endl;
- cin>>letter ;
- cout<<"字元"<<letter<<"所對應的ASCII碼為"<<int(letter);
- break;
-
- case 3:
- goto end;
-
- default:
- cout<<"輸入錯誤"<<endl;
- }
- cout<<endl;
- goto start;
- end:
- system("pause");
- return 0;
- }
複製代碼 |