返回列表 發帖

字串處理 (五) - 英文大小寫轉換

本帖最後由 王瑞喻 於 2020-4-9 21:02 編輯

運用 strupr() 函式 與 strlwr() 函式進行英文大小寫轉換

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);    //string upper
  11.     cout<<"轉換為大寫: "<<str<<endl;
  12.     strlwr(str);    //string lower
  13.     cout<<"轉換為小寫: "<<str<<endl;
  14.     system("pause");     
  15.     return 0;   
  16. }
複製代碼
Su Wa

  1. #include<cstdlib>
  2. #include<string>
  3. #include<iostream>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);
  11.     cout<<"轉為大寫: "<<str<<endl;
  12.     strlwr(str);
  13.     cout<<"轉為小寫: "<<str<<endl;
  14.     system("pause");
  15.     return 0;
  16. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"請輸入任一英文字串: ";
  9.     cin.getline(str,50);
  10.     cout<<"轉為大寫: "<<strupr(str)<<endl;
  11.     cout<<"轉為小寫: "<<strlwr(str)<<endl;
  12.     system("pause");     
  13.     return 0;   
  14. }
複製代碼
Jian-wei Wang

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);
  11.     cout<<"轉換為大寫: "<<str<<endl;
  12.     strlwr(str);
  13.     cout<<"轉換為小寫: "<<str<<endl;  
  14.     system("pause");     
  15.     return 0;     
  16. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);    //string upper
  11.     cout<<"轉換為大寫: "<<str<<endl;
  12.     strlwr(str);    //string lower
  13.     cout<<"轉換為小寫: "<<str<<endl;
  14.     system("pause");     
  15.     return 0;   
  16. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);
  11.     cout<<"轉換為大寫: "<<str<<endl;
  12.     strlwr(str);
  13.     cout<<"轉換為小寫: "<<str<<endl;
  14.     system("pause");     
  15.     return 0;   
  16. }
複製代碼
Vincent

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.    char str[50];
  8.    int n;
  9.    cout<<"請輸入一任意英文字串:";
  10.    cin.getline(str,50);
  11.    strupr(str);
  12.    cout<<"轉換為大寫:"<<str<<endl;
  13.    strlwr(str);
  14.    cout<<"轉換為小寫:"<<str<<endl;
  15.    system("pause");
  16.    return 0;   
  17. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     char s[100];
  7.     cout<<"輸入一字串: ";
  8.     cin.getline(s,100);
  9.     cout<<"大寫: "<<strupr(s)<<endl;
  10.     cout<<"小寫: "<<strlwr(s)<<endl;
  11.     system("pause");
  12.     return 0;
  13. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);   
  11.     cout<<"轉換為大寫: "<<str<<endl;
  12.     strlwr(str);   
  13.     cout<<"轉換為小寫: "<<str<<endl;
  14.     system("pause");     
  15.     return 0;   
  16. }
複製代碼
蔡少宇

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);  
  11.     cout<<"轉換為大寫: "<<str<<endl;
  12.     strlwr(str);  
  13.     cout<<"轉換為小寫: "<<str<<endl;
  14.     system("pause");     
  15.     return 0;   
  16. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);    //string upper
  11.     cout<<"轉換為大寫: "<<str<<endl;
  12.     strlwr(str);    //string lower
  13.     cout<<"轉換為小寫: "<<str<<endl;
  14.     system("pause");     
  15.     return 0;   
  16. }
複製代碼

TOP

返回列表