當前位置:首頁 » 操作系統 » 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;
}

熱點內容
excel怎麼破解密碼 發布:2025-03-17 20:49:32 瀏覽:358
v10系統電腦怎麼連接伺服器 發布:2025-03-17 20:43:39 瀏覽:984
如何給應用設密碼是什麼 發布:2025-03-17 20:32:25 瀏覽:472
歡迎訪問河南工業大學 發布:2025-03-17 20:31:40 瀏覽:17
fw源碼 發布:2025-03-17 20:13:17 瀏覽:65
java培訓機構排行 發布:2025-03-17 19:59:53 瀏覽:588
java異常使用 發布:2025-03-17 19:06:38 瀏覽:723
餐飲劇情抖音短視頻腳本 發布:2025-03-17 19:03:18 瀏覽:506
gg傳奇腳本 發布:2025-03-17 18:56:30 瀏覽:757
學霸導師安卓密碼忘了怎麼辦 發布:2025-03-17 18:43:36 瀏覽:486