我真的会谢,求大佬帮帮我(bushi)

#include<iostream>

#include<cstdio>

using namespace std;

int main()

{

char ch;

bool f=false;

int num=0;

while((ch=getchar())!='\n');

{

if(f)

if(ch>='0'&&ch<='9')

num++;

else break;

if(ch=='.')f=true;

}

if(num>0)

cout<<num<<endl;

else

cout<<"输入不正确!"<<endl;

return 0;

}

14 8 C:\Users\Administrator\Documents\下册10(第3题).cpp [Error] break statement not within loop or switch

他这么说的

全部评论
while语句后面有个分号,循环体是空的,break语句在循环体外面肯定报错。然后else默认最近的if,你对f的判断要加个大括号。而且你到底要实现什么功能?
点赞 回复
分享
发布于 2022-11-06 11:27 四川
输入1.6,输出1;输入90.909090,输出6。我是想计算小数点后有几位,如9.849678 小数点后有'849678&(32934)#39;6位数字,所以输出6。
点赞 回复
分享
发布于 2022-11-06 17:40 河北
滴滴
校招火热招聘中
官网直投
点赞 回复
分享
发布于 2022-11-06 19:15 四川

相关推荐

1 收藏 评论
分享
牛客网
牛客企业服务