问题九十二:字符统计
[plain]
#include<stdio.h>
#include<string.h>
int main()
{
long a;
long b;
long c;
long d;
long i;
long k;
char n[100000];
while(gets(n) !=NULL)
{
a=b=c=d=0;
k=strlen(n);
for(i=0; i<k; i++)
{
if( (n[i]>='a' && n[i]<='z') || (n[i]>='A' && n[i]<='Z') )
a++;
else if(n[i]>='0' &&n [i]<='9')
b++;
else if(n[i]==' ')
c++;
else
d++;
}
printf("%ld %ld %ld %ld\n", a, b, c, d);
}
#include<stdio.h>
#include<string.h>
int main()
{
long a;
long b;
long c;
long d;
long i;
long k;
char n[100000];
while(gets(n) !=NULL)
{
a=b=c=d=0;
k=strlen(n);
for(i=0; i<k; i++)
{
if( (n[i]>='a' && n[i]<='z') || (n[i]>='A' && n[i]<='Z') )
a++;
else if(n[i]>='0' &&n [i]<='9')
b++;
else if(n[i]==' ')
c++;
else
d++;
}
printf("%ld %ld %ld %ld\n", a, b, c, d);
} [plain] view plaincopyprint?return 0
return 0[plain] view plaincopyprint?}
}
补充:软件开发 , C语言 ,