读书人

大家帮帮忙,看一下这个程序解决思路

发布时间: 2012-03-05 11:54:02 作者: rapoo

大家帮帮忙,看一下这个程序
#include <iostream>
#include <cctype>
int main()
{
using namespace std;
char ch;
cout < < "enter something:(@to exit) ";
while(cin.get(ch),ch!= '@ ')
{
if (isdigit(ch)) //判断不是不数字
{
if (isupper(ch)) //判断是不是大写,是大写返回TRUE
ch = tolower(ch); //将大写转换为小写
else if (islower(ch)) //判断是不是小写,是小写返回TRUE
ch = toupper(ch); //将小写转换为大写
}
cout < <ch;
}
return 0;
}

大家帮忙看一下,我要的目的是输入@后才能回车显示输入的内容,但现在是没有输入@只要回车就显示输入的内容,不知道是哪里错了,

[解决办法]
cout < <ch;在循环的里面,当然输不输出和是否输入了@了无关了...

读书人网 >C++

热点推荐