#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; }
时间: 2024-11-05 06:13:48