標題:
字串的處理 (八) - ASCII碼與字元相互查詢
[打印本頁]
作者:
tonyh
時間:
2014-1-4 15:12
標題:
字串的處理 (八) - ASCII碼與字元相互查詢
本帖最後由 tonyh 於 2014-1-4 15:25 編輯
#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;
goto re;
end:
system("pause");
return 0;
}
複製代碼
作者:
劉泳鱔
時間:
2014-1-4 15:24
#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;
}
複製代碼
作者:
林以諾
時間:
2014-1-4 15:25
#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;
}
複製代碼
作者:
張瀚仁
時間:
2014-1-4 15:25
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int start,end,a,b;
char a;
re:
cout<<"1ascii轉字母 2字母轉ascii 3結束"<<endl;;
cin>>start;
switch(start)
{
case 1:
cout<<"請輸入ASCII碼: ";
cin>>end;
cout<<"字元為: "<<char(end);
break;
case 2:
cout<<"請輸入字元: ";
cin>>a;
cout<<"ASCII為: "<<int(a);
break;
case 3:
goto end;
break;
default:
cout<<"輸入錯誤"<<endl;
}
cout<<endl;
goto re:
end:
system("pause");
return 0;
}
複製代碼
作者:
鎧言
時間:
2014-1-4 15:26
#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;
goto re;
end:
system("pause");
return 0;
}
複製代碼
作者:
郭凡瑛
時間:
2014-1-4 15:29
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int start,end,a,b;
char a;
re:
cout<<"1ascii轉字母 2字母轉ascii 3結束"<<endl;;
cin>>start;
switch(start)
{
case 1:
cout<<"請輸入ASCII碼: ";
cin>>end;
cout<<"字元為: "<<char(end);
break;
case 2:
cout<<"請輸入字元: ";
cin>>a;
cout<<"ASCII為: "<<int(a);
break;
case 3:
goto end;
break;
default:
cout<<"輸入錯誤"<<endl;
}
cout<<endl;
goto re:
end:
system("pause");
return 0;
}
複製代碼
作者:
黃崇維
時間:
2014-1-17 18:06
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int ascii, option;
char letter;
cout<<"(1)ascii轉字元 (2)字元轉ascii (3)結束"<<endl;
cout<<"請選擇: ";
cin>>option;
switch(option)
{
case 1:
cout<<"輸入ascii: ";
cin>>ascii;
cout<<"ascii碼"<<ascii<<"所對應的字元為: "<<char(ascii)<<endl;
break;
case 2:
cout<<"輸入字元: ";
cin>>letter;
cout<<"字元"<<letter<<"所對應的ascii碼為: "<<int(letter)<<endl;
break;
case 3:
goto end;
break;
default:
cout<<"輸入錯誤!"<<endl;
}
goto re;
end:
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2