分享
 
 
 

用C写的简单学生成绩管理系统

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

/* Copyright (c) 2004 aprin

*

*

*/

#include <stdio.h>

#include <string.h>

#define MAXN 35

#define MAX_NAME 256

typedef struct student{

int no;

char name[MAX_NAME];

int english;

int math;

int computer;

int mark_ave;

int mark_tot;

} STUDENT;

/*-----------input sub program---------*/

void input(STUDENT *data, int *len)

{

int no;

char ch[MAX_NAME];

int mark;

putchar('\n');

printf("%s\n", "Enter the new records.And if you want exit, enter -1.");

printf("%s\n", "format: number");

printf("%s\n", " name english math computer average total");

putchar('\n');

printf("such as:\n");

printf("1\n");

printf("Gates 100 100 100 100 400\n");

scanf("%d", &no);

while(no != -1) {

data[*len].no = no;

scanf("%s %d %d %d %d %d", data[*len].name, &data[*len].english, &data[*len].math,

&data[*len].computer, &data[*len].mark_ave, &data[*len].mark_tot);

(*len)++;

scanf("%d", &no);

}

}

/*---------------output sub program---------------*/

void output(STUDENT *data, int len)

{

int i;

clrscr();

printf("%8s", "number");

printf("%8s", "name");

printf("%8s", "english");

printf("%8s", "math");

printf("%10s", "computer");

printf("%12s", "average");

printf("%10s", "total");

putchar('\n');

for (i =0; i < 80; i++)

putchar('=');

putchar('\n');

for (i = 0; i< len; i++)

{

printf("%8d", data[i].no);

printf("%8s", data[i].name);

printf("%8d", data[i].english);

printf("%8d", data[i].math);

printf("%10d", data[i].computer);

printf("%12d", data[i].mark_ave);

printf("%10d", data[i].mark_tot);

putchar('\n');

}

for (i =0; i < 80; i++)

putchar('=');

putchar('\n');

printf("Press enter to continue.");

getchar();

getchar();

}

/*--------------sort sub program------------*/

void sort(STUDENT *data, int len)

{

int i,j,k;

STUDENT temp;

for (i=0; i<len-1; i++) {

for (k=i, j=i+1; j<len; j++)

if (data[k].mark_ave > data[j].mark_ave) k=j;

if (k != i) {

temp = data[i];

data[i] = data[k];

data[k] = temp;

}

}

}

/*--------------------find sub program-----------------------*/

void find(STUDENT *data, int len)

{

int find_no, result ;

int i;

lab: result=0;

printf("%s\n", "Enter the number which you want to find. If you want exit, enter -1.");

scanf("%d", &find_no);

if (find_no == -1) return; /*exit the fine sub program*/

while( data[result].no != find_no && result < len) result ++;

if (result >= len ) {

printf("%s\n", "There is no the record which you want.");

goto lab;

}

else {

clrscr();

printf("%s\n", "The flowing record is you want.");

for (i =0; i < 80; i++)

putchar('=');

putchar('\n');

printf("%8s", "number");

printf("%8s", "name");

printf("%8s", "english");

printf("%8s", "math");

printf("%10s", "computer");

printf("%12s", "average");

printf("%10s", "total");

putchar('\n');

printf("%8d", data[result].no);

printf("%8s", data[result].name);

printf("%8d", data[result].english);

printf("%8d", data[result].math);

printf("%10d", data[result].computer);

printf("%12d", data[result].mark_ave);

printf("%10d", data[result].mark_tot);

putchar('\n');

for (i =0; i < 80; i++)

putchar('=');

putchar('\n');

goto lab;

}

}

/*-----------------insert sub program-------------*/

void insert(STUDENT *data, int *len)

{

int no, pos, english, math, computer, mark_ave, mark_tot, i;

char name[MAX_NAME];

lab: printf("%s\n", "Enter the new records. If you want exit, enter -1.");

printf("%s\n", "format: number");

printf("%s\n", " name english math computer average total");

scanf("%d", &no);

if (no == -1) return;

data[*len].no = no;

scanf("%s %d %d %d %d %d", name, &english, &math, &computer, &mark_ave, &mark_tot);

pos = 0;

while ((data[pos].mark_ave < mark_ave) && (pos < *len) )

pos ++;

for (i = *len-1; i >= pos; i--)

data[i+1] = data[i];

data[pos].no = no;

strcpy(data[pos].name, name);

data[pos].english = english;

data[pos].math = math;

data[pos].computer = computer;

data[pos].mark_ave = mark_ave;

data[pos].mark_tot = mark_tot;

(*len)++;

goto lab;

}

/*--------------delete sub program--------------*/

void delete(STUDENT *data, int *len)

{

int no, i, pos;

lab: pos=0;

printf("%s\n", "Enter the number which you want to delete. If you want exit, enter -1.");

scanf("%d", &no);

if (no == -1) return;

while( (data[pos].no != no) && (pos < *len) ) pos = pos +1;

if (pos >= *len) {

printf("%s\n", "There is no the record which you want.");

goto lab;

}

else {

for (i = pos+1;i < *len; i++)

data[i-1] = data[i];

*len = *len -1;

if (*len == 0) {

printf("%s\n", "The number of records is zero, press enter to return.");

getchar();

getchar();

return;

}

goto lab;

}

}

/*---------------stat sub program------------*/

void stat(STUDENT *data, int len)

{

int no_59=0, no_69=0, no_79=0, no_89=0, no_100=0;

int i;

for (i = 0;i < len; i++) {

if (data[i].mark_ave <=59) no_59++;

else if (data[i].mark_ave <=69) no_69++;

else if (data[i].mark_ave <=79) no_79++;

else if (data[i].mark_ave <= 89) no_89++;

else no_100++;

}

clrscr();

for (i =0; i < 80; i++)

putchar('=');

putchar('\n');

printf("%10s", "score");

printf("%10s", "0--59");

printf("%10s", "60--69");

printf("%10s", "70--79");

printf("%10s", "80--89");

printf("%10s", "90--100");

putchar('\n');

putchar('\n');

printf("%10s", "student");

printf("%10d", no_59);

printf("%10d", no_69);

printf("%10d", no_79);

printf("%10d", no_89);

printf("%10d", no_100);

putchar('\n');

for (i =0; i < 80; i++)

putchar('=');

putchar('\n');

printf("Press enter to return.");

getchar();

getchar();

}

/*---------------manu------------*/

void paint()

{

int i;

clrscr();

printf("%43s\n", "Manu");

for (i = 0; i < 80; i++)

putchar('=');

putchar('\n');

printf(" 1 input 2 output\n");

printf(" 3 sort(average) 4 find(number)\n");

printf(" 5 insert 6 delete(number)\n");

printf(" 7 stat(average) 0 quit\n");

for (i = 0; i<= 79; i++)

putchar('=');

putchar('\n');

printf("%s\n", "Please enter the command:");

}

/*------------main program---------------*/

main()

{

STUDENT data[MAXN];

int len = 0;

char ctrl_ch;

paint();

scanf("%c", &ctrl_ch);

while (ctrl_ch != '0') {

switch(ctrl_ch) {

case '1':

input(data, &len);

break;

case '2':

output(data, len);

break;

case '3':

sort(data, len);

break;

case '4':

find(data, len);

break;

case '5':

insert(data, &len);

break;

case '6':

delete(data, &len);

break;

case '7':

stat(data, len);

break;

default:

if (ctrl_ch != '\n') printf("%s\n", "Error command.");

break;

}

if (ctrl_ch != '\n') paint();

scanf("%c", &ctrl_ch);

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有