C++大小写
C++ 如何将大写字符改为小写,小写改为大写qaq #include <iostream>using namespace std;
int main()
{
char letter = {0};
int i = 0;
while (1)
{
cout << "请输入字母:";
cin >> letter;
for (i=0; letter != 0; i++)
{
if (int(letter) >= 65 && int(letter) <= 90)
{
letter = int(letter) + 32;
}
else if (int(letter) >= 97 && int(letter) <= 122)
{
letter = int(letter) - 32;
}
}
cout << "\n转换后的字母:" << letter << "\n\n";
cout << "==========================================================\n\n";
}
return 0;
}
页:
[1]