本帖最後由 邱博宥 於 2024-10-5 18:48 編輯
- #include<iostream>
- #include<ctime>
- #include<string>
- #include<algorithm>
- using namespace std;
- void big(char* a)
- {
- for(int c=0; a[c]!='\0'; c++)
- {
- if(a[c] >='a' && a[c]<='z')
- {
- a[c]-=32;
- }
- }
- }
- void small(char* a)
- {
- for(int c; a[c]!='\0'; c++)
- {
- if(a[c] >='A' && a[c]<='Z')
- a[c]+=32;
- }
- }
- int main()
- {
- char a[100];
- cout<<"請輸入一串句子:";
- cin.getline(a,100);
- big(a);
- cout<<"轉換成大寫是:"<<a<<endl;
- small(a);
- cout<<"轉換成小寫是:"<<a;
- return 0;
- }
複製代碼 |