文章

3

粉丝

403

获赞

3

访问

34.6k

头像
能运行,结果输出没问题,但是现实 runtime error
P1052
发布于2020年1月18日 01:24
阅读数 10.7k

#include <stdio.h>

typedef struct{ 
    int Sno;  //学号
    char clas[50];//班级
    char name[50];//姓名    注意!c语言中没有string类型
    double c1,c2,c3;//课程1成绩
}student;//学生结构体

student s[50];//定义学生数组结构体全局变量

void InputStudent(student *s,int n){//输入n个学生的数据,传入参数为指针,因为数组的地址相当于s
                                     //名称相当于指针,常用n来决定传入数组的长度
    for(int i=0;i<n;i++){//给n个学生输入
        scanf("%d%s%s%lf%lf%lf",&s[i].Sno,s[i].clas,s[i].name,
              &s[i].c1,&s[i].c2,&s[i].c3);//lf为double的匹配占位符
    }
}

double averagescore(student s){//求学生的平均成绩
    return (s.c1+s.c2+s.c3)/3;

int maxscoreIndex(student *s,int n){
    doub...

登录查看完整内容


登录后发布评论

2 条评论
buluoxu
2024年3月21日 16:10

给的数组太小了,多给点

赞(0)
arcsinX
2020年7月21日 11:28

student s[100];//修改此处可以AC,但不知何故

 

赞(0)