17.cpp
来自「经典C语言程序设计100例1-10 如【程序1】 题目:有1、2、3、4」· C++ 代码 · 共 32 行
CPP
32 行
/*---------------------------------------例题17-------------------------------------------------------------------*/
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int nchar = 0, none = 0, num = 0, nelse = 0 ;
char a;
cout<<"input some characters:"<<endl;
while( !cin.eof())
{
cin.get(a);
if((a<='z' && a>='a')||(a<='Z' && a>='A'))
nchar++;
else if(a==' ')
none++;
else if(a<='9' && a>='0')
num++;
else
nelse ++;
}
cout<<"The number of char is "<<nchar<<'.'<<endl;
cout<<"The number of number is "<<num<<'.'<<endl;
cout<<"The number of space is "<<none<<'.'<<endl;
cout<<"The number of other characters is "<<(nelse-1)<<'.'<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?