- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- char string[100];
- cout<<"請輸入任意字串(100字內):"<<endl;
- cin.getline(string,100);
- cout<<"此字串的ASCLL字元碼依序為:"<<endl;
- for(int i=0; i<100 && string[i]!=NULL; i++)
- {
- if(int(string[i])>65 && int (string[i])<=90)
- {
- cout<<"第"<<i+1<<"個字元的ASCLL碼為"
- <<int(string[i])<<",大寫"<<endl;
- }else if(int(string[i])>96 && int(string[i])<=122)
- {
- cout<<"第"<<i+1<<"個字元的ASCLL碼為"
- <<int(string[i])<<",小寫"<<endl;
- }else
- {
- cout<<"您打的字串不是字母"<<endl;
- }
-
- }
-
-
- system("pause");
- return 0;
- }
複製代碼 |