编译的时候没错,执行的时候出问题 明明是输入三十个成绩求平均值最大值最小值,但只输入一个它就出结果了 还看不懂
贴下代码
#include<iostream>
using namespace std;
int main(){
int i=0;
int count = 30;
int s[count];
int sum=0,max,min;
while (i<count)
{
cin>> s[i];
i++;
}
i = 0;
while (i<count)
{
sum += s[i];
i++;
}
max = s[0];
min = s[0];
i = 0;
while (i<count)
{
if (max<s[i])
max=s[i];
if (min>s[i])
min=s[i];
i++;
}
cout<<"avg="<<sum/count<<endl;
cout<<"max="<<max<<endl;
cout<<"min="<<min<<endl;
return 0;
}
你把代码发出来吧,要不然我们的回答只是我们的想法,不能指出你的错误。