困惑中

yiren2 2008-03-25 09:58:51
#include<iostream>
#include<cctype>
void main(){
using namespace std;

double aa[10],ave,sum(0.0),ch;
int i,n(0),b(0);

for(i=0;i<10;i++)
{//ch=cin.get();
cin>>ch;
if (isdigit(ch))
{aa[i]=ch;b++;
//ch=cin.get();}
cin>>ch;}
else break;}

for(i=0;i<b;i++)
{sum+=aa[i];}
ave=sum/b;
cout<<sum<<endl;
cout<<ave<<endl;
for(i=0;i<b;i++)
{if(aa[i]>ave)
n++;
}
cout<<n<<endl;
}
为什么运行出来是乱码
...全文
65 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
星羽 2008-03-25
  • 打赏
  • 举报
回复

#include "iostream"
using namespace std;

void main()
{
..........
}
ryfdizuo 2008-03-25
  • 打赏
  • 举报
回复
重新编译一下就可以了,没什么关系的,
yiren2 2008-03-25
  • 打赏
  • 举报
回复
谢谢啊,还是有一个错误,什么意思啊
fatal error LNK1168: cannot open Debug/gg.exe for writing
Error executing link.exe.
ryfdizuo 2008-03-25
  • 打赏
  • 举报
回复
void main()
{
using namespace std;

double aa[10],ave,sum(0.0);
char ch;
int i,n(0),b(0);

cin>>ch;
for(i=0;i <10;i++)
{
if (isdigit(ch))
{
aa[i]= (double) (ch-'0');
b++;
cin>>ch;
}
else break;
}
for(i=0;i <b;i++)
{sum+=aa[i];}
ave=sum/b;
cout <<sum <<endl;
cout <<ave <<endl;
for(i=0;i <b;i++)
{
if(aa[i]>ave)
n++;
}
cout <<n <<endl;
}
ryfdizuo 2008-03-25
  • 打赏
  • 举报
回复
if (isdigit(ch)) 
这个判断没有意义啊,你这里ch是int,所以if里面的就没有执行,

65,176

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧