C++ 急用,跪谢大神 有一个一维数组,内放n个学生成绩,输出各分数段人数,平均分,最
C++急用,跪谢大神有一个一维数组,内放n个学生成绩,输出各分数段人数,平均分,最高分和最低分,保留小数点后一位。要求:(1)分数段人数,平均分,最高分和最低分分别由三个...
C++ 急用,跪谢大神 有一个一维数组,内放n个学生成绩,输出各分数段人数,平均分,最高分和最低分,保留小数点后一位。要求:(1) 分数段人数,平均分,最高分和最低分分别由三个或四个子函数完成 (2)保留小数点后一位
展开
1个回答
展开全部
#include <iostream>
using namespace std;
void main()
{
int a[10] = {60, 70, 80, 90, 66, 77, 88, 99, 100, 89};
int count[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int max = a[0];
int min = a[0];
int i;
double avg = a[0];
for (i = 1; i < 10; i++)
{
if (max < a[i])
{ max = a[i]; }
if (min > a[i])
{ min = a[i]; }
avg += a[i];
count[a[i] / 10]++;
}
avg /= 10;
cout << "最高分:" << max << endl;
cout << "最低分:" << min << endl; cout << "平均分:" << avg << endl;
for (i = 0; i < 10; i++)
{
cout << 10 * i << "~" << 10 * i + 9 << "人数:" << count[i] << endl;
}
cout << 100 << "人数:" << count[i] << endl;
}
using namespace std;
void main()
{
int a[10] = {60, 70, 80, 90, 66, 77, 88, 99, 100, 89};
int count[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int max = a[0];
int min = a[0];
int i;
double avg = a[0];
for (i = 1; i < 10; i++)
{
if (max < a[i])
{ max = a[i]; }
if (min > a[i])
{ min = a[i]; }
avg += a[i];
count[a[i] / 10]++;
}
avg /= 10;
cout << "最高分:" << max << endl;
cout << "最低分:" << min << endl; cout << "平均分:" << avg << endl;
for (i = 0; i < 10; i++)
{
cout << 10 * i << "~" << 10 * i + 9 << "人数:" << count[i] << endl;
}
cout << 100 << "人数:" << count[i] << endl;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询