c++基础问题
c吧
全部回复
仅看楼主
level 1
wzg547228197 楼主
# include <iostream>
# include <cctype>
using namespace std;
int main()
{
char ch;
cout << "Please enter a characters, I'll repeat it until '@': ";
while(cin.get(ch))
{
if(ch == '@')
break;
if(isdigit(ch))
continue;
if(isupper(ch))
ch = tolower(ch);
if(islower(ch))
ch = toupper(ch);
cout << ch;
}
cout << endl;
return 0;
}
求问上面的代码。输入小写能转换为大写 但是为什么大写转化不了小写啊?
2015年08月21日 12点08分 1
level 14
if(isupper(ch))
ch = tolower(ch);
if(islower(ch))
ch = toupper(ch);
你好好想想,如果是大写,执行这段代码会发生什么
2015年08月21日 12点08分 2
懂了!!谢谢啦!!
2015年08月21日 12点08分
level 9
应该用if else 不然先转换成小写,然后又被转换成大写。。。
2015年08月21日 18点08分 3
1