YUU


私信TA

用户名:uq_77405186617

访问量:1693

签 名:

来个大佬带带我吧

等  级
排  名 2218
经  验 2332
参赛次数 1
文章发表 16
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:



参考代码:

#include<iostream>
using namespace std;
typedef struct{
    char x[10];
    char name[10];
    double a;
    double b;
    double c;
    double ave;
}student;
student *input(){
    student *s=new student;
    cin>>s->x;
    cin>>s->name;
    cin>>s->a;
    cin>>s->b;
    cin>>s->c;
    s->ave=(s->a+s->b+s->c)/3;
    return s;
}
int main()
{
    int n;
    cin>>n;
    student *s[n];
    for(int i=0;i<n;i++){
        s[i]=input();
    }
    double t1=0,t2=0,t3=0,Max=0;
    int m;
    for(int i=0;i<n;i++){
        t1+=s[i]->a;
        t2+=s[i]->b;
        t3+=s[i]->c;
        if(s[i]->ave>Max){
            Max=s[i]->ave;
            m=i;
        }
    }
    t1=t1/n;t2=t2/n;t3=t3/n;
    cout<<t1<<" "<<t2<<" "<<t3<<endl;
    cout<<s[m]->x<<" "<<s[m]->name<<" "<<s[m]->a<<" "<<s[m]->b<<" "<<s[m]->c;
    return 0;
}


 

0.0分

3 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区