|
楼主 |
发表于 2019-4-25 21:06:24
|
显示全部楼层
#include<iostream>
#include<string.h>
using namespace std;
int sum =0;
double a[100];
class student
{
double name; double yu;
public:
student()
{
name = 0;
yu = 0;
};
void set(double name1, double yu1)
{
name = name1;
yu = yu1;
}
friend double average(const student* p, int count);
};
double average(const student* p, int count)
{
double max = 0;
double m;
//cout << count<<"wer";
for (int i = 0; i < count; i++)
{
max = p[0].yu;
if (p[i].yu >= max)
max = p[i].name;
}
for (int i = 0; i <count; i++)
{
if (p[i].yu == max)
{
a[sum] = p[i].name;
sum++;
}
}
return max;
}
int main()
{
student St[100];
long name;
int num = 0;
double yu;
double yes;
while ((cin >> name) && name != 0 && name >= 00001 && name <= 99999)
{
cin >> yu;
St[num].set(name, yu);
num++;
}
yes = average(St, num);
//cout << sum << "io";
if(sum==0)
cout << yes;
else
{
for (int i = 0; i <num; i++)
{
cout << a[i] << " ";
}
}
return 0;
}
|
|