#include <stdio.h>
extern int system(const char *);
int main()
{
void squ(char * str,int * p1,int * p2);
int matchNum(char * s);
int matchLetter(char * s);
int a=0,b=0;
char input[50];
printf("Please input a string...\n");
gets(input);
squ(input,&a,&b);
printf("There are %d number(s) and %d letter(s) above.\n",a,b);
system("pause");
return 0;
}
void squ(char * str,int * p1,int * p2)
{
for(;;){
if(*str=='\0')break;
if(matchNum(str)){
(*p1)++;
}
if(matchLetter(str)){
(*p2)++;
}
str++;
}
}
int matchNum(char * s)
{
if(*s>=48 && *s<=57){
return 1;
}
else{
return 0;
}
}
int matchLetter(char * s)
{
if((*s>='a' && *s<='z')||(*s>='A' && *s<='Z')){
return 1;
}
else{
return 0;
}
}
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/d788d43f8794a4c2b2402b3307f41bd5ad6e3943?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)