文章

7

粉丝

309

获赞

5

访问

64.2k

头像
输入输出均没问题,也写成函数;但提交Compilation Error
P1052
发布于2020年2月6日 01:05
阅读数 9.0k

#include<stdio.h>
#include<malloc.h>

int n;
struct student{
    char id[20];
    char class_name[20];
    char name[20];
    double g1,g2,g3,avg;
    };
void data_in(struct student *q){
    struct student* p=NULL;
    p=q;

    for(int i=0;i<n;i++){
        scanf("%s %s %s %lf %lf %lf",p[i].id,p[i].class_name,p[i].name,&p[i].g1,&p[i].g2,&p[i].g3);
           }


}
void cal_ave(struct student *q){
    struct student* p=NULL;
    p=q;
    for(int i=0;i<n;i++){
        p[i].avg=(p[i].g1+p[i].g2+p[i].g3)/3;//不能用p[i]->g1
    }
}

int cal_max(struct student *p){
    double max_avg=0;
    int pos=0;
    for(int i=0;i<n;i++){
        if(p[i].avg>=max_avg){
    &nb...

登录查看完整内容


登录后发布评论

3 条评论
admin SVIP
2020年2月9日 11:08

是不是选错语言了,用C++提交试一下

赞(1)

LiW97 : 回复 admin: 试了不是~~

2020年2月9日 23:10

admin : 回复 admin: 可以在编译错误的代码页面看到编译错误的信息,和用编译器一样的

2020年2月13日 11:27