}
else if ('0'=<str[i]&& str[i]<='9')
{
++digit;
}
else if (str[i]= =' ' )
{
++space;
}
else
++other;
}
printf("英文字符数:%d\n", letter);
printf("数字字符数:%d\n", digit);
printf("空格数:%d\n", space);
printf("其他字符数:%d\n", other);
}
答案:
1)define ARR_SIZE = 80 改为 define ARR_SIZE 80
2)if (a=<str[i]<=z && A=<str[i]<=Z)
改为if ( a =<str[i]&& str[i]<= z || A =<str[i]&&str[i]<= Z )
6、任意输入一个字符串,在星期表中查找该字符串,若找到,则打印 “已找到”,否则打印 “没找到”。
#include<string.h>
main()
{
int i;
int findFlag;
char x[10];
char weekDay[7][10]= {
"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; findFlag=0;
printf("请输入一个字符串:");
scanf("%s",x);
for (i=0; i < 7 && !findFlag; i++)
{
改为: if (strcmp(x ,weekDay[i])= =0) {