#include<stdio.h>
#define size 100
int* num(char c[]);
int* num(char c[]){
static int letter,figure,blank,other; letter=0;figure=0;blank=0;other=0; int i=0; for(i=0;c[i]!='\0';i++){
if(('A'<=c[i]&&c[i]<='Z')||('a'<=c[i]&&c[i]<='z')) letter++; else if('0'<=c[i]&&c[i]<='9') figure++;
else if(c[i]==' ') blank++;
else other++;}
static int a[4]={letter,figure,blank,other};
return a; }
int main(){
int i,*t;
char ch[size];
gets(ch); t=num(ch);
for(i=0;i<4;i++)
printf("%d\n",*(t+i));
}
由实参传字符串,统计字符串中字母数字空格和其他字符的个数
于 2022-12-07 21:44:52 首次发布