输入一批任意数量的正整数,使用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无用
悬赏问题
- ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
- ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
- ¥15 Google speech command 数据集获取
- ¥15 vue3+element-plus页面崩溃
- ¥15 像这种代码要怎么跑起来?
- ¥15 怎么改成循环输入删除(语言-c语言)
- ¥15 安卓C读取/dev/fastpipe屏幕像素数据
- ¥15 pyqt5tools安装失败
- ¥15 mmdetection
- ¥15 nginx代理报502的错误