|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
调用函数#include<stdio.h>
struct student
{
int xuehao;
char name[29];
double chengji[5];
};
void input(int k, struct student *p)
{
int j,i,max,o;
double *v;
struct student *t;
v=(double *)malloc(100*sizeof(double *));
t=(struct student *)malloc(100*sizeof(struct student *));
printf("%s %s %s %s %s %s %s\n","学号","姓名","英语","高数","马哲","计算机","电子技术");
for (j=0;j<k;j++)
{
scanf("%d %s %lf %lf %lf %lf %lf",&p[j].xuehao,p[j].name,&p[j].chengji[0],&p[j].chengji[1],&p[j].chengji[2],&p[j].chengji[3],&p[j].chengji[4]);
}
for (j=0;j<k;j++)
{
for (i=0;i<k-j;i++)
{
if (p[i-1].xuehao>p[i].xuehao)
{
t[i]=p[i-1];
p[i-1]=p[i];
p[i]=t[i];
}
}
}
PrintScoreeg(k,p);
}
被调用函数void PrintScoreeg(int a,struct student *b)
{
int j;
printf("\n");
printf("课程名称:英语\n");
printf("——————————————\n");
printf("%s\t%s\t%s\n","学号","姓名","英语");
printf("\n");
printf("——————————————\n");
for (j=0;j<a;j++)
{
printf("%d\t%s\t%lf",b[j].xuehao,b[j].name,b[j].chengji[0]);
printf("\n");
}
}
主函数
void main()
{
struct student *s;
unsigned int num;
printf("请输入学生的个数\n");
scanf("%d", &num);
s=(struct student *)malloc(100*sizeof(struct student *));
printf("请输入学生信息\n");
input(num,s);
free(s);
} |
|