输入一批任意数量的正整数,使用for循环控制统计其中不大于100的数值个数。这是问题
#include <stdio.h>
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元补偿
c语言的for循环问题
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
qzjhjxj 2022-10-22 16:56关注改动处见注释,供参考:
#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; }本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 1无用