练习3-4 统计字符(15 分)water

#include<stdio.h>

int main()
{
    int letter=0,digit=0,blank=0,other=0;
    int i;
    char ch;

    for(i=0;i<=9;i++){
        scanf("%c",&ch);
        if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')) 
               letter++;
        else if(ch>='0'&&ch<='9') 
               digit++;
        else if(ch==' '||ch=='\n') 
               blank++;
        else 
               other++;
    }
      scanf("%c",&ch);
     printf("letter = %d, blank = %d, digit = %d, other = %d",letter,blank,digit,other);

     return 0;
 } 

猜你喜欢

转载自blog.csdn.net/Cathy1122334455/article/details/82082078