題目鏈接
問題描述
撰寫一個程式,輸入一個字串(長度不超過20),然后把這個字串內的每一個字符進行大小寫變換,即將大寫字母變成小寫,小寫字母變成大寫,然后把這個新的字串輸出,
輸入格式:輸入一個字串,而且這個字串當中只包含英文字母,不包含其他型別的字符,也沒有空格,
輸出格式:輸出經過轉換后的字串,
輸入輸出樣例
樣例輸入
AeDb
樣例輸出
aEdB
代碼:
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
while(cin >> s)
{
int len = s.length();
for(int i = 0; i < len; i++)
if(s[i] >= 97 && s[i] <= 122) s[i] -= 32;
else if(s[i] >= 65 && s[i] <= 90) s[i] += 32;
cout << s << endl;
}
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/258947.html
標籤:其他
上一篇:ctf學習筆記
