
用c语言编一简单在线考试系统 20
2个回答
展开全部
# include <stdio.h>
# include <stdlib.h>
struct student //定义了一个结构体类型
{
int age; //年龄
float score; //分数
char name[111] ;//名字
};
void h(int e,struct student * w)
{
int i;
for(i=0;i<e;i++)
{
printf("第%d个学生的信息\n",i+1);
printf("age=%d\n",w[i].age);
printf("name=%s\n",w[i].name);
printf("score=%f\n",w[i].score);
printf("\n");
}
}
void g(int q,struct student * o )
{
int j;
int k;
struct student t;
for(j=0;j<q;j++)
{
for(k=0;k<q-1-j;k++)
{
if(o[k].score > o[k+1].score)
{
t=o[k];
o[k]=o[k+1];
o[k+1]=t;
}
}
}
h(q,o);
}
void f(int r,struct student * m,int v)
{
int i;
for(i=0;i<r;i++)
{
printf("请输入%d班第%d个学生的信息\n",v,i+1);
printf("age=");
scanf("%d",&m[i].age);
printf("name=");
scanf("%s",m[i].name);
printf("score=");
scanf("%f",&m[i].score);
}
g(r,m);
}
void z(void)
{
struct student p;
int len;
int m;
printf("班级");
scanf("%d",&m);
printf("输入%d班学生个数\n",m);
scanf("%d",&len);
p=(struct student )malloc(sizeof(struct student)*len);
f(len,p,m);
}
int main(void)
{
z();
z();
z();
return 0;
}
# include <stdlib.h>
struct student //定义了一个结构体类型
{
int age; //年龄
float score; //分数
char name[111] ;//名字
};
void h(int e,struct student * w)
{
int i;
for(i=0;i<e;i++)
{
printf("第%d个学生的信息\n",i+1);
printf("age=%d\n",w[i].age);
printf("name=%s\n",w[i].name);
printf("score=%f\n",w[i].score);
printf("\n");
}
}
void g(int q,struct student * o )
{
int j;
int k;
struct student t;
for(j=0;j<q;j++)
{
for(k=0;k<q-1-j;k++)
{
if(o[k].score > o[k+1].score)
{
t=o[k];
o[k]=o[k+1];
o[k+1]=t;
}
}
}
h(q,o);
}
void f(int r,struct student * m,int v)
{
int i;
for(i=0;i<r;i++)
{
printf("请输入%d班第%d个学生的信息\n",v,i+1);
printf("age=");
scanf("%d",&m[i].age);
printf("name=");
scanf("%s",m[i].name);
printf("score=");
scanf("%f",&m[i].score);
}
g(r,m);
}
void z(void)
{
struct student p;
int len;
int m;
printf("班级");
scanf("%d",&m);
printf("输入%d班学生个数\n",m);
scanf("%d",&len);
p=(struct student )malloc(sizeof(struct student)*len);
f(len,p,m);
}
int main(void)
{
z();
z();
z();
return 0;
}
追问
这不是我要的,不过谢谢了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询