Ϊʲôֹͣ²»ÁËÊäÈ룿ÊäÈëÒ»ÐÐ×Ö·û£¬·Ö±ðͳ¼Æ³öÆäÖеÄÓ¢ÎÄ×Öĸ¡¢¿Õ¸ñ¡¢Êý×ÖºÍÆäËü...
#include<stdio.h>#include <stdlib.h>
int main()
{
int a,b,c,d,e;//a ÊÇÓÃÀ´Í³¼ÆÓ¢ÎÄ×Öĸb ÊÇÓÃÀ´Í³¼Æ¿Õ¸ñcÊÇÓÃÀ´Í³¼ÆÊý×ÖdÊÇÓÃÀ´Í³¼ÆÆäËû×Ö·û
a=b=c=d=0;
while((e=getchar())!='/n')
{
if((e >= 'a' && e <= 'z')||(e >= 'A' && e <= 'Z'))
{a++;
}
else if(e==' ')
{b++;
}
else if(e>='0'||e<='9')
{
c++;
}
else
d++;
}
printf("%d %d %d %d",a,b,c,d);
} while((e=getchar())!='/n') ÖУ¬Ó¦¸Ãд³É\n£¬²»ÊÇ/n
#include<stdio.h>
#include <stdlib.h>
int main()
{
int a,b,c,d,e;//a ÊÇÓÃÀ´Í³¼ÆÓ¢ÎÄ×Öĸb ÊÇÓÃÀ´Í³¼Æ¿Õ¸ñcÊÇÓÃÀ´Í³¼ÆÊý×ÖdÊÇÓÃÀ´Í³¼ÆÆäËû×Ö·û
a=b=c=d=0;
while((e=getchar())!='\n')
{
if((e >= 'a' && e <= 'z')||(e >= 'A' && e <= 'Z'))
{a++;
}
else if(e==' ')
{b++;
}
else if(e>='0'||e<='9')
{
c++;
}
else
d++;
}
printf("%d %d %d %d",a,b,c,d);
}
תÒå×Ö·û¿ªÍ·Ó¦¸ÃÊÇ·´Ð±¸Ü
Ò³:
[1]