标签:
#include "stdafx.h" #include<iostream> using namespace std; void count(char *c) { if(c==NULL) return; int zimu=0; int shuzi=0; int kongge=0; int qita=0; while(*c) { if((*c>=‘a‘&&*c<=‘z‘)||(*c>=‘A‘&&*c<=‘Z‘)) zimu++; else if(*c==‘ ‘) kongge++; else if(*c>=‘0‘&&*c<=‘9‘) shuzi++; else qita++; c++; } cout<<zimu<<endl; cout<<kongge<<endl; cout<<shuzi<<endl; cout<<qita; cout<<endl; } int main() { char s[100]; cin.getline(s,100); count(s); system("pause"); return 0; }
输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数-简单题
标签:
原文地址:http://my.oschina.net/u/2350638/blog/498855