内容:读取键盘输入,直达输入‘@’符号,然后回显输入(数字不用)。把大写字符变成小写,把小写字符变成大写。
方法一:使用ASCII码
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
char ch;
string s;
cin>>ch;
while(ch!='@')
{
if(ch>='A' && ch<='Z') s+=(ch+32);
else if(ch>='a' && ch<='z') s+=(ch-32);
cin>>ch;
}
cout<<s;
return 0;
}