|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#include<iostream.h>
void main()
{
char c;
int letters = 0, space = 0, digit = 0, others = 0;
cout<<"please input some characters:";
while ((c = getchar()) != '\n')
{
if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
letters++;
else if (c == ' ')
space++;
else if (c >= '0' && c <= '9')
digit++;
else
others++;
}
cout<<"letters="<<letters<<endl
<<" space="<<space<<endl
<<" digit="<<digit<<endl
<<" others="<<others<<endl;
}
cout<<"please input some characters:"; //为什么要在这句后面加上<<endl;在开始显示的时候才能显示please input some characters:呢?如果不加的话,运行时只有一个光标在跳动,谁知道给解释一下,谢谢
不要说编译器版本之类的问题,我想知道问题的本质,还有我知道endl具有双层意思,换行和涮新缓存,但是不能很好的掌握和理解第二重意思,望大虾的指教!!! |
|