標題:
ASCII碼與字元相互查詢
[打印本頁]
作者:
tonyh
時間:
2012-5-5 16:23
標題:
ASCII碼與字元相互查詢
本帖最後由 tonyh 於 2012-5-5 17:07 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int option, ascii;
char letter;
start:
cout<<"1-輸入ASCII碼查詢字元 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<<"輸入錯誤!";
}
cout<<endl<<endl;
goto start;
end:
system("pause");
return 0;
}
複製代碼
作者:
t2364705
時間:
2012-5-5 17:02
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int option, ascii;
char letter;
start:
cout<<"1.輸入ASCII碼查詢字元 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;
default:
cout<<"輸入錯誤!";
}
cout<<endl;
goto start;
end:
system("pause");
return 0;
}
複製代碼
作者:
劉漢文
時間:
2012-5-5 17:04
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int option, ascii;
char letter;
start:
cout<<"1.輸入ASCII碼尋字元 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<<"字元"<<ascii<<"所對應的ASCII碼為"<<int(letter);
break;
case 3:
goto end;
default:
cout<<"輸入錯誤!";
}
cout<<endl;
goto start;
end:
system("pause");
return 0;
}
複製代碼
作者:
t3742238
時間:
2012-5-5 17:04
#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;
}
複製代碼
作者:
尤泓鈞
時間:
2012-5-5 17:07
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int option , ascii;
char letter;
start:
cout<<"1-請輸入ASCII碼查詢字元2-請輸入字元查詢ASCII碼3-結束程式"<<endl;
cout<<"請選擇"<<endl;
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;
break;
default:
cout<<"輸入錯誤"<<endl;
}
cout<<endl;
goto start;
end:
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2