题目:
Problem Description:
输入一个字符串,统计其中大写字母、小写字母、数字的个数
Input:
输入数据有多组,每组数据占一行,为一个字符串s (1 <= |s| <= 100)。
数据保证字符串中只有’A’-'Z’的大写字母,‘a’-'z’的小写字母,和’0’到’9’的数字
Output:
对于每组数据,输出以空格隔开的三个整数,分别表示大写字母的个数,小写字母的个数,数字的个数
Sample Input:
a34bU
OIU5dda98P
Sample Output:
1 2 2
4 3 3
代码如下:[color=#FF0000]为什么一直报wrong answer[/color]
#include<stdio.h>
int main()
{
int i,temp;
int low,up,num;
char s[101];
for(i=0;i<101;i++)
{
s[i]=’+’;
}
while(scanf("%s",s)!=EOF)
{
if(s[100]!='+'&&s[100]!='\0')
return 0;
low=0;
up=0;
num=0;
for(i=0;i<101;i++)
{
temp=(int)s[i];
if((temp>=97)&&(temp<=122))
low++;
if((temp>=65)&&(temp<=90))
up++;
if((temp>=48)&&(temp<=57))
num++;
}
printf("%d",up);
printf(" ");
printf("%d",low);
printf(" ");
printf("%d\n",num);
}
return 0;
}