c语言课程设计 学生综合测评系统

更新时间:2024-06-23 23:55:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

include #include #include #define true 1 struct student {

char name[60]; char ID[7]; int score; };

int dq(struct student st[]); void xianshi();

void bc(struct student st[]); void add(); void select(); void zz();

void chazhao(); void xhcz(); void xmcz(); void del(); void xmsc(); void xhsc(); void tj(); void bjg(); void xg(); void xhxg(); void xmxg(); void bca(); void fh();

struct student st[300]; int Number=0; void main() {

int choose=0; FILE *fp=NULL; char yesorno;

if((fp=fopen(\ {

printf(\提示:文件不存在,是否要创建一个?(y/n)\\n\ scanf(\

if(yesorno=='y'||yesorno=='Y') {

fp=fopen(\ fclose(fp); } else

exit(0); } else {

Number=dq(st); }

system(\ while(true) {

xianshi();

printf(\请选择:\ scanf(\ system(\ switch(choose) {

case 0: exit(0);fh();break; case 1: add();fh();break; case 2: select();fh();break; case 3: chazhao();fh();break; case 4: del();fh();break; case 5: tj();fh();break; case 6: bjg();fh();break; case 7: xg();fh();break; case 8:zz();fh();break; case 9:bca();break; default:break; }

fflush(stdin); getchar(); system(\ } }

void bca() {

printf(\程序在运行时已自动保存.....\\n\ }

void fh() {

printf(\按Enter键返回主菜单\\n\ }

void xg() {

int way=0;

printf(\请选择修改查找方式\\n\ printf(\按姓名查找修改\\n\ printf(\按学号查找修改\\n\ scanf(\ switch(way) {

case 1: xmxg();break;

case 2: xhxg();break;

default: printf(\输入有误,结束!\\n\ } }

void xmxg() {

FILE *fp=NULL; char name[60]; int i=0;

int changeIndex=0; int index=0;

printf(\请输入要修改的学生姓名:\ scanf(\

for (i=0;i

if (strcmp(name,st[i].name)) {

changeIndex=i; } break; }

printf(\姓名\\t学号\\t成绩\\n\

printf(\ndex].score);

printf(\请重新输入该学生信息\

printf(\姓名:\

scanf(\ printf(\学号:\

scanf(\ printf(\成绩:\

scanf(\

fp=fopen(\ for (i=0;i

fwrite(&st[i],sizeof(struct student),1,fp); }

fclose(fp); }

void xhxg() {

FILE *fp=NULL; char id[60]; int i=0;

int changeIndex=0; int index=0;

printf(\请输入要修改的学生学号:\ scanf(\

for (i=0;i

if (strcmp(id,st[i].ID)) {

changeIndex=i; }

break; }

printf(\姓名\\t学号\\t成绩\\n\

printf(\ndex].score);

printf(\请重新输入该学生信息\

printf(\姓名:\

scanf(\ printf(\学号:\

scanf(\ printf(\成绩:\

scanf(\

fp=fopen(\ for (i=0;i

fwrite(&st[i],sizeof(struct student),1,fp); }

fclose(fp);

printf(\修改成功\\n\ }

void bjg() {

int i=0;

printf(\以下是不及格:\\n\

printf(\姓名\\t学号\\t成绩\\n\ for (i=0;i

if (st[i].score <60) {

printf(\ } } }

void tj() {

int i=0;

double sum=0.0;

for(i=0;i

sum+=st[i].score; }

printf(\全班总分为:%f\\n\ printf(\平均分为:%f\\n\ }

void del() {

int n=0;

printf(\按姓名删除\\n\

printf(\按学号删除\\n\ scanf(\ switch(n) {

case 1: xmsc();break; case 2: xhsc();break; } }

void xmsc() {

FILE *fp=NULL; char name[60]; int i=0; int j=0;

printf(\请输入要删除的学生姓名:\ scanf(\

for(i=0;i

if(strcmp(name,st[i].name)==0) {

for (j=i;j

st[j]=st[j+1]; }

Number--; } }

fp=fopen(\ for (i=0;i

fwrite(&st[i],sizeof(struct student),1,fp); }

fclose(fp);

printf(\删除成功;\\n\ }

void xhsc() {

FILE *fp=NULL; char id[60]; int i=0; int j=0;

printf(\请输入要删除的学生学号:\ scanf(\

for(i=0;i

if (strcmp(id,st[i].ID)==0) {

for (j=i;j

st[j]=st[j+1]; }

Number--; } }

fp=fopen(\ for (i=0;i

fwrite(&st[i],sizeof(struct student),1,fp); }

fclose(fp);

printf(\删除成功;\\n\ }

void chazhao() {

int n=0;

printf(\按姓名查找\\n\

printf(\按学号查找\\n\ scanf(\ switch(n) {

case 1: xmcz();break; case 2: xhcz();break;

default: printf(\输入有误,结束!\\n\ break; } }

void xhcz() {

char id[7]; int i=0;

printf(\请输入要查找学生学号:\ scanf(\ system(\

printf(\姓名\\t学号\\t成绩\\n\ for(i=0;i

if (strcmp(id,st[i].ID)==0) {

printf(\ } } }

void xmcz() {

char name[7]; int i=0;

printf(\请输入要查找学生姓名:\ scanf(\ system(\

printf(\姓名\\t学号\\t成绩\\n\ for (i=0;i

if (strcmp(name,st[i].name)==0) {

printf(\ } } }

void zz() {

printf(\n\\n\

printf(\《学生成绩管理系统》 ^^^^^^^^^^\\n\\n\

printf(\四川省托普信息技术职业学院 ^^^^^^^^^^\\n\\n\

printf(\级计算机网络技术IBM2班 ^^^^^^^^^^\\n\\n\

printf(\周桂修改 ^^^^^^^^^^\\n\\n\ printf(\n\\n\ }

void select() {

int i=0;

printf(\以下是全部学生成绩\\n\

printf(\姓名\\t学号\\t成绩\\n\ for(i=0;i

printf(\ } }

void add() {

int numberTemp=0; int i=0;

struct student temp;

printf(\请输入要增加学生成绩个数:\ scanf(\ for(i=0;i

printf(\输入第%d个同学信息\\n\ printf(\姓名:\

scanf(\ printf(\学号:\

scanf(\ printf(\成绩:\

scanf(\ st[Number++]=temp; bc(&temp); }

printf(\添加成功\\n\ }

void bc(struct student *st) {

FILE *fp=NULL;

fp=fopen(\ fwrite(st,sizeof(struct student),1,fp); fclose(fp); }

int dq(struct student st[]) {

FILE *fp=NULL; int i=0;

fp=fopen(\

while(fread(&st[i],sizeof(struct student),1,fp)) i++;

fclose(fp); return i; }

void xianshi() {

printf(\******\\n\

printf(\

printf(\学生成绩管理系统 *\\n\ printf(\

printf(\增加学生成绩 [2] 查看学生成绩 *\\n\ printf(\查找学生成绩 [4] 删除学生成绩 *\\n\ printf(\统计(总成绩和平均分)[6] 输出不及格人数 *\\n\ printf(\修改学生信息 [8] 关于作者 *\\n\

printf(\保存数据 [0] 退出系统 *\\n\

printf(\******\\n\ }

本文来源:https://www.bwwdw.com/article/a8v3.html

Top