|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include <stdlib.h>
int main()
{
int letter,digit,blank,other;
char c;
letter=digit=blank=other=0;
printf("Please enter a sentence:");
while((c=getchar())!='/n')
{
if((c>='A'&&c<='Z')||(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",letter,blank,digit,other);
return 0;
}
各位能帮我看看吗?不知道为什么这段代码始终运行不了
- #include <stdio.h>
- #include <stdlib.h>
- int main(void)
- {
- int letter, digit, blank, other;
- char c;
- letter = digit = blank = other = 0;
- printf("Please enter a sentence:");
- while ((c = getchar()) != '\n') // 应该是\n,/n是错的
- {
- if ((c >= 'A' && c <= 'Z') || (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", letter, blank, digit, other);
- return 0;
- }
复制代码
|
-
|