为什么用>= 运行结果不能出来
#include<stdio.h>main()
{
int score;
printf("input a score:");
scanf("%d\n",&score);
if (score<60)
{
printf("The score is E");
}
else if (score>=60&&score<70)
{
printf("The score is D");
}
else if (score>=70&&score<80)
{
printf("The score is C");
}
else if (score>=80&&score<90)
{
printf("The score is B");
}
else
{
printf("The score is A");
}
} 这一句是错的
scanf("%d\n",&score);
必须改成这样
scanf("%d",&score); scanf里面别要\n了,它没有什么用{:10_250:}
#include<stdio.h>
main()
{
int score;
printf("input a score:");
scanf("%d",&score);
if (score<60)
{
printf("The score is E");
}
else if (score>=60&&score<70)
{
printf("The score is D");
}
else if (score>=70&&score<80)
{
printf("The score is C");
}
else if (score>=80&&score<90)
{
printf("The score is B");
}
else
{
printf("The score is A");
}
}
小甲鱼的铁粉 发表于 2020-11-30 21:27
scanf里面别要\n了,它没有什么用
\n不是换行吗?
jackz007 发表于 2020-11-30 21:26
这一句是错的
必须改成这样
\n 不是换行吗?怎么不行?
别认识我 发表于 2020-11-30 21:32
\n 不是换行吗?怎么不行?
printf() 里面可以这么用,scanf() 里面除了格式描述符以外,最好不要有任何其它字符,否则,键盘输入的时候容易出现莫名其妙的现象。 jackz007 发表于 2020-11-30 21:35
printf() 里面可以这么用,scanf() 里面除了格式描述符以外,最好不要有任何其它字符,否则,键盘 ...
好,谢谢
我正常运行了啊~ 你把scanf 括号里的 换行符\n删掉。再试试
页:
[1]