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