有大佬会这个吗?期末到了,求帮忙!!
https://wenku.baidu.com/view/20315730b4daa58da0114a34.html
题目描述不太清晰,主程我不知道你要干什么?只好仅写个读入。
showMenu()函数没写,不知道你是啥意思。max函数也不太明白,但还是写了,你看是不是你要的吧。
# include <cstdio>
using namespace std;
struct Student{
int no;
char xm[20];
double sc1, sc2, sc3, sc;
} stu[100];
int n;
void cal(){
for(int i = 1; i <= n; i++)
stu[i].sc = stu[i].sc1 * 0.6 + stu[i].sc2 * 0.3 + stu[i].sc3 * 0.1;
}
double aver(){
int sum = 0;
for(int i = 1; i <= n; i++)
sum += stu[i].sc;
return 1.0 * sum / n;
}
void sort(){
for(int i = 1; i <= n; i++)
for(int j = i + 1; j <= n; j++)
if(stu[i].sc < stu[j].sc){
Student T = stu[i];
stu[i] = stu[j];
stu[j] = T;
}
}
int search(int x){
int flag = -1;
for(int i = 1; i <= n; i++)
if(stu[i].no == x){
flag = i;
break;
}
return flag;
}
int max(){
int flag = -1;
int now = 0;
for(int i = 1; i <= n; i++)
if(now < stu[i].sc){
now = stu[i].sc;
flag = i;
}
return flag;
}
void output(){
for(int i = 1; i <= n; i++)
printf("%d %s %.3f %.3f %.3f %.3f\n", stu[i].no, stu[i].xm, stu[i].sc1, stu[i].sc2, stu[i].sc3, stu[i].sc);
}
int main()
{
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d%s%lf%lf%lf", &stu[i].no, stu[i].xm, &stu[i].sc1, &stu[i].sc2, &stu[i].sc3);
return 0;
}
/*
5
1 a 51 62 80
2 b 84 88 90
3 c 95 90 95
4 d 62 73 80
5 e 73 66 90
*/