[C++] 纯文本查看 复制代码
#include <iostream>
using namespace std;
int main()
{int i,j,upper,lower,digit,space,other;
char text[3][80];
upper=lower=digit=space=other=0;
for (i=0;i<3;i++)
{cout<<"please input line "<<i+1<<endl;
gets(text);
for (j=0;j<80 && text[j]!='\0';j++)
{if (text[j]>='A'&& text[j]<='Z')
upper++;
else if (text[j]>='a' && text[j]<='z')
lower++;
else if (text[j]>='0' && text[j]<='9')
digit++;
else if (text[j]==' ')
space++;
else
other++;
}
}
cout<<"upper case:"<<upper<<endl;
cout<<"lower case:"<<lower<<endl;
cout<<"digit :"<<digit<<endl;
cout<<"space :"<<space<<endl;
cout<<"other :"<<other<<endl;
return 0;
}