当前位置:首页 » 操作系统 » c考试系统源码

c考试系统源码

发布时间: 2023-07-08 16:07:56

c语言 程序考试报名管理系统

#include<stdio.h>
#include<stdlib.h>
#defineSTU_NUM10/*宏定义学生的数量*/
structstudent/*定义一个结构体用来存放学生学号、三门课成绩、总分及平均成绩*/
{
charstu_id[20];/*学生学号;*/
floatscore[3];/*三门课成绩;*/
floattotal;/*总成绩;*/
floataver;/*平均成绩;*/
};
/*排序用一个函数来实现*/
voidSortScore(student*stu,intn)
{
studentstud;
for(inti=0;i<n-1;i++)
for(intj=i+1;j<n;j++)
{
if(stu[i].total<stu[j].total)
{
stud=stu[i];
stu[i]=stu[j];
stu[j]=stud;
}
}
}
intmain()
{
studentstu[STU_NUM];/*创建结构体数组中有10个元素,分别用来保存这10个人的相关信息。*/
/*输入这十个学生的相关信息*/
for(inti=0;i<STU_NUM;i++)
{
printf("请输入第%d个学生的学号:",i+1);
scanf("%s",&stu[i].stu_id);
printf("输入第%d个学生的数学成绩:",i+1);
scanf("%f",&stu[i].score[0]);
printf("输入第%d个学生的英语成绩:",i+1);
scanf("%f",&stu[i].score[1]);
printf("输入第%d个学生的计算机成绩:",i+1);
scanf("%f",&stu[i].score[2]);
stu[i].total=stu[i].score[0]+stu[i].score[1]+stu[i].score[2];
stu[i].aver=stu[i].total/3;
}
printf(" ");

SortScore(stu,STU_NUM);/*调用排序函数*/
/*输出排序后的各学生的成绩*/
for(i=0;i<STU_NUM;i++)
{
printf("序号:%d ",i);
printf("学号:%s ",stu[i].stu_id);
printf("数学:%f ",stu[i].score[0]);
printf("英语:%f ",stu[i].score[1]);
printf("计算机:%f ",stu[i].score[2]);
printf("平均成绩:%f ",stu[i].aver);
printf("总分:%f ",stu[i].total);
printf(" ");
}
return0;
}
注:(源程序中主要标识符含义说明)
#defineSTU_NUM10/*宏定义学生的数量*/
structstudent/*定义一个结构体用来存放学生学号、三门课成绩、总分及平均成绩*/
{
charstu_id[20];/*学生学号;*/
floatscore[3];/*三门课成绩;*/
floattotal;/*总成绩;*/
floataver;/*平均成绩;*/
}

㈡ 用c语言编一简单在线考试系统

# 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;
}

热点内容
微信存储到sd卡 发布:2025-03-18 01:34:29 浏览:968
eclipse的自动编译 发布:2025-03-18 01:34:29 浏览:367
可以上传视频网站 发布:2025-03-18 01:29:17 浏览:932
mysql密码忘记了怎么 发布:2025-03-18 01:23:00 浏览:858
java与oracle 发布:2025-03-18 01:18:05 浏览:705
怎么给win7电脑文件加密 发布:2025-03-18 01:10:41 浏览:989
python生成随机数 发布:2025-03-18 01:10:40 浏览:95
手机存储卡怎么设置 发布:2025-03-18 01:04:26 浏览:213
背算法好处 发布:2025-03-18 01:02:18 浏览:57
win7添加删除在哪个文件夹 发布:2025-03-18 01:02:13 浏览:705