|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <stdio.h>
- struct subjects
- {
- int Math;
- int Physic;
- int English;
- };
- typedef struct subjects subjects;
- int main()
- {
- int num;
- struct Student
- {
- int ID;
- char name[20];
- int subjects;
- int ave;
- };
- typedef struct Student Student;
-
- void Dealing( int n , Student *stu1 );
- Student stu[10];
- scanf("%d",&num);
- Dealing(num,stu);
- }
- void Dealing( int n , Student *stu1 )
- {
- int i,Ave;
- for(i=0;i<n;i++)
- {
- scanf("%d%s%d%d%d",&stu[i].ID,stu[i].name,&stu[i].subjects.Math,&stu[i].subjects.Physic,&stu[i].subjects.English);
- Ave = (stu[i].subjects.Physic + stu[i].subjects.English +stu[i].subjects.Math)/3.0;
- stu[i].ave=Ave;
- }
- }
复制代码
大体思路就是用结构体存放数据,但是格式有问题,不知道哪里出了问题,请帮忙看一下
- #include <stdio.h>
- struct subjects
- {
- int Math;
- int Physic;
- int English;
- };
- typedef struct subjects subjects;
- struct Student
- {
- int ID;
- char name[20];
- //int subjects;
- subjects subjects;
- int ave;
- };
- typedef struct Student Student;
- int main()
- {
- int num;
- void Dealing( int n , Student *stu1 );
- Student stu[10];
- scanf("%d",&num);
- Dealing(num,stu);
- return 0;
- }
- void Dealing( int n , Student *stu1 )
- {
- int i,Ave;
- for(i=0;i<n;i++)
- {
- scanf("%d%s%d%d%d",&stu1[i].ID,stu1[i].name,&stu1[i].subjects.Math,&stu1[i].subjects.Physic,&stu1[i].subjects.English);
- Ave = (stu1[i].subjects.Physic + stu1[i].subjects.English +stu1[i].subjects.Math)/3.0;
- stu1[i].ave=Ave;
- }
- }
复制代码
|
|