输入一个正整数 repeat (0<repeat<10),做repeat 次下列运算:
输入一行字符,分别统计出其中的英文字母、空格、数字和其他字符的个数。
2
acm.zcmu.edu.cn/JudgeOnline ACMICPC.
AC Neng Nian Lai Guo Dao.
letter=30,blank=1,digit=0,other=5
letter=19,blank=5,digit=0,other=1
#include<stdio.h>
int main()
{int n,letter,blank,other,digit;
scanf("%d",&n);
char c;
getchar();
while(n--!=0){letter=0;blank=0;other=0;digit=0;
while((c=getchar())!='\n'){
if(c>='a'&&c<='z'){letter++;
} else if(c>='A'&&c<='Z'){letter++;
} else if(c>='0'&&c<='9'){digit++;
} else if(c==' '){blank++;
} else{other++;
}
}
printf("letter=%d,blank=%d,digit=%d,other=%d\n",letter,blank,digit,other);
}
return 0;
}