作业3(3)

#include<stdio.h>
int main(void)
{
    int letter,blank,digit,other;/*定义整数型变量*/
    char ch;
    int i;
    letter=blank=digit=other;
    printf("Enter 15 characters:");
    for(i=1;i<=15;i++){/*判断当i<=15时*/
        ch=getchar();
        if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))/*判断*/
  letter++;
  else if(ch>='0'&&ch<='9')
  digit++;
  else if((ch='\n')||(ch=' '))
  blank++;
  else
  other++;
  
 }
 printf("letter=%d,digit=%d,blank=%d,other=%d\n",letter,digit,blank,other);
 return 0;
}

posted @ 2013-10-19 22:02  跃映峰影  阅读(87)  评论(1编辑  收藏  举报