输入一批任意数量的正整数,使用for循环控制统计其中不大于100的数值个数。这是问题
#include
int main()
{
printf("please input interal numbers and input 0 to stop:");
long int a, b;
for(a=0;b!=0;a++)
{
scanf("%ld", &b);
if (b<100)
continue;
printf("\n");
}
printf("suitable number: %d\n", a-1);
}
错在哪里了,运行不出来啊,帮忙打出来谢谢。加v2元补偿
改动处见注释,供参考:
#include <stdio.h>
int main()
{
printf("please input interal numbers and input 0 to stop:");
long int a, b;
for(a=0;b!=0;) //修改
{
scanf("%ld", &b);
if (b <= 100){ //修改
a++; //修改
continue;
}
//printf("\n");
}
printf("suitable number: %ld\n", a-1);
return 0;
}
#include <stdio.h>
int main()
{
printf("please input interal numbers and input 0 to stop:");
long int a, b;
while(scanf("%ld",&b)!=EOF)
{
if(b>100)
{
a++;
}
}
printf("suitable number: %ld\n", a-1);
return 0;
}
这样就可以了,在平台上是可以过的,自己测试需要Ctrl+Z
平台上会自动加的
有用记得采纳呐