本文实例为大家分享了c语言实现学生成绩管理系统项目,供大家参考,具体内容如下
1、数据结构:学生信息:学号、姓名、年龄、性别、3课成绩
2、功能:
(1) 增加学生记录
(2) 删除学生记录
(3) 查找学生信息(学号、姓名)
(4) 修改学生信息
(5) 按照成绩排序、求平均值、最大值、最小值
3、用户界面
主菜单
子菜单
4、 批量生成测试数据
//// main.c// student system//// created by ma c on 15/7/22.// copyright (c) 2015年. all rights rerved.// 要求:编写一个学生成绩管理系统。#include <stdio.h>#include<string.h>#include<stdlib.h>#define n 50struct student{ char name[20]; int sno; int age; char gender; float englishscore; float mathsco品质意识培训资料re; float chinescore;}stu[n]={{"zhao",1000,20,'m',98,99,97}, {"zhao",1001,21,'f',97,96,95}, {"qian",1002,23,'m',95,96,92}, {"hong",1003,22,'f',91,93,97}, {"zhou",1004,25,'m',90,90,90}, {"feng",1005,21,'f',96,93,96}, {"wang",1006,23,'m',97,91,90}, {"chen",1007,21,'f',94,92,91}, {"geng",1008,20,'f',90,99,91}, {"tang",1009,24,'m',99,99,99}};//添加数据void add(struct student stu[],int pos,int nums);//删除数据void delete_name(struct student *stu,char name[]);//(按姓名)void delete_sno(struct student *stu,int sno);//(按学号)//修改数据void update(struct student stu[],int sno,int len);//查询子菜单void menu(struct student stu[],int m);void arch(struct student stu[],int n,char name[]);//按姓名查询void arch1(struct student stu[],int n,int num);//按学号查询void sort(struct student stu[],int n); //按总分高低排序void print(struct student stu[],int n);void my_print_sum(struct student stu[],int n);void max_min(struct student stu[],int n);//主菜单void printscreen(){ printf("------------------\n"); printf("** 1.增加学生记录 **\n"); printf("** 2.删除学生记录 **\n"); printf("** 3.查找学生记录 **\n"); printf("** 4.修改学生记录 **\n"); printf("** 0.退出管理系统 **\n"); printf("------------------\n");}//删除子菜单void deletescreen(){ printf("------------------\n"); printf("** 0.按姓名删除数据**\n"); printf("** 1.按学号删除数据**\n"); printf("** 2.返回主菜单 **\n"); printf("------------------\n"); printf("plea lect 0-1:");}//查找子菜单void ekscreen(){ printf("-------------------------\n"); printf("****** 1.按姓名查找信息 *\n"); printf("****** 2.按学号查找信息 *\n"); printf("****** 3.查看所有学生成绩 *\n"); printf("****** 4.成绩名次排序(总分)*\n"); printf("****** 5.查看成绩最优最差 *\n"); printf("****** 6.返回主菜单 *\n"); printf("-------------------------\n"); printf("plea you lect 1-6:");}//定义全局静态变量,统计目前结构体数组中的人数static int count = 10;//主函数int main(int argc, const char * argv[]){int nums,temp;int snos;char names[20];while(1){ printscreen(); printf("plea press enter_key continue!\n"); getchar(); printf("plea lect 0-4:"); char c = getchar(); switch(c) { ca '1': printf("plea student'numbers you want to add:"); scanf("%d",&nums); add(stu,count,nums); //添加数据 getchar(); break; ca '2': deletescreen(); scanf("%d",&temp); switch(temp) { ca 0: printf("plea input delete name:"); scanf("%s",names);; delete_name(stu,names); //删除数据(按姓名删除) break; ca 1: printf("plea input delete sno:"); scanf("%d",&snos); delete_sno(stu,snos); //删除数据(按学号删除) break; ca 2: break; } getchar(); break; ca '3': menu(stu,count);//查找数据 getchar(); 甜甜的 周杰伦 break; ca '4': printf("plea input update sno:"); scanf("%d",&snos); update(stu,snos,count); //修改数据 break; ca '0': exit(0); //退出系统 default: printf("data is illeagel!\n"); getchar(); break; //输入非法 }}return 0;}//添加数据void add(struct student stu[],int pos,int nums)//开始位置、添加人数{ for(int i=pos;i<pos+nums;i++) { printf("plea input name:"); scanf("%s",stu[i].name); int flag = 1,sno; while(flag) { printf("plea input sno:"); scanf("%d",&sno); for(int j=0;j<pos;j++) { if(stu[j].sno==sno) { printf("sno is exist!\n"); break; } el { flag = 0; } } stu[i].sno = sno; } printf("plea input age:"); scanf("%d",&stu[i].age); printf("plea input gender:(f/m or f/m)"); getchar(); scanf("%c",&stu[i].gender); printf("plea input englishscore:"); scanf("%f",&stu[i].englishscore); printf("plea input mathscore:"); scanf("%f",&stu[i].mathscore); printf("plea input chine南京大专score:"); scanf("%f",&stu[i].chinescore); printf("学生信息添加成功!\n"); } count = count + nums;}//按学号删除void delete_sno(struct student *stu,int sno){ if(count==0) { printf("成员已为空!\n"); return; } int flag=0; for(int i=0;尊老爱老敬老i<count;i++) { if((stu+i)->sno==sno) { for(int j=i;j<count;j++) { *(stu+j)=*(stu+j+1); } printf("\n"); printf("学号为%d的学生已被删除\n",sno); printf("\n"); flag=1; count = count-1; break; } } if(flag==0) printf("学号%d不存在.\n",sno);}//按姓名删除void delete_name(struct student *stu,char name[]){ if(count==0) { 心态正能量printf("成员已为空!\n"); return; } int flag=0; int n=count; for(int i=0;i<n;i++) { if(strcmp((stu+i-flag)->name,name)==0) { for(int j=i-flag;j<count;j++) { *(stu+j)=*(stu+j+1); } printf("\n"); printf("学生:%s 已被删除.\n",name); printf("\n"); flag=flag+1; count =count -1; } } if(flag==0) printf("学生:%s 不存在.\n",name);}//修改数据void update(struct student stu[],int sno,int len){ char cs,cs1,cs2,cs3; char p[20]; int grade,i; for(i=0; i<len; i++) { if(sno==stu[i].sno) { printf("plea ask update name?(y/n):"); getchar(); cs = getchar(); if(cs == 'y') { printf("plea input a new name:"); scanf("%s",p); getchar(); strcpy(stu[i].name,p); printf("update is succeed!\n"); } printf("plea ask update englishscore?(y/n):"); cs1 = getchar(); if(cs1 == 'y') { printf("plea input a new grade:"); scanf("%d",&grade); stu[i].englishscore = grade; printf("update is succeed!\n"); } printf("plea ask update mathscore?(y/n):"); getchar(); cs2 = getchar(); if(cs2 == 'y') { printf("plea input a new grade:"); scanf("%d",&grade); stu[i].mathscore = grade; printf("update is succeed!\n"); } printf("plea ask update chinescore?(y/n):"); getchar(); cs3 = getchar(); if(cs3 == 'y') { printf("plea input a new grade:"); scanf("%d",&grade); stu[i].chinescore = grade; printf("update is succeed!\n"); break; } el { getchar(); break; } } el if(i==len-1) { printf("error,don't have the sno!"); break; } el { continue; } }}//查询数据void menu(struct student stu[],int m){ int logel = 1; while(logel) { ekscreen(); int n; scanf("%d",&n); char name[20]; int num; switch(n) { ca 1 : printf("请输入同学的姓名: "); scanf("%s",name); arch(stu,count,name); break; ca 2 : printf("\n请输入同学的学号: "); scanf("%d",&num); arch1(stu,count,num); break; ca 3: print(stu,count); break; ca 4: sort(stu,count); print(stu,count); break; ca 5: max_min(stu,count); break; ca 6: logel = 0; break; default: logel = 0; printf("输入数字有误!\n"); break; } }}void arch(struct student stu[],int n,char name[]){ char* p= name; int flag = 0; for(int i=0;i<n;i++) { if(strcmp(stu[i].name,p)==0) { flag = 1; my_print_sum(stu,i); } } if(flag==0) { printf("the name is not exist!\n"); }}void arch1(struct student stu[],int n,int num){ int flag = 0; for(int i=0;i<n;i++) { if(num==stu[i].sno) { flag = 1; my_print_sum(stu,i); } } if(flag==0) { printf("the sno is not exist!\n"); }}void sort(struct student stu[],int n){ float sum[n]; for(int i=0;i<n;i++) { sum[i]=stu[i].englishscore+stu[i].mathscore+stu[i].chinescore; } for(int i=0;i<n-1;i++) { for(int j=0;j<n-1-i;j++) { if(sum[j]<sum[j+1]) { float temp1 = sum[j]; sum[j] = sum[j+1]; sum[j+1] = temp1; struct student temp; temp=stu[j]; stu[j]=stu[j+1]; stu[j+1]=temp; } } }}void max_min(struct student stu[],int n){ sort(stu,n); printf("成绩最优的同学:"); my_print_sum(stu,0); printf("成绩最差的同学:"); my_print_sum(stu,n-1);}void print(struct student stu[],int n){ for(int i=0;i<n;i++) { my_print_sum(stu,i); }}void my_print_sum(struct student stu[],int n){ printf("\n姓名:%s,学号:%d,年龄:%d,性别:%c,英语:%.2f,数学:%.2f,语文: %.2f,总分:%.2f\n", stu[n].name,stu[n].sno,stu[n].age,stu[n].gender, stu[n].englishscore,stu[n].mathscore,stu[n].chinescore,(stu[n].englishscore+stu[n].mathscore+stu[n].chinescore));}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持www.887551.com。
本文发布于:2023-04-04 21:06:44,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/75f3ca82f3cd64393502f8ab5822365f.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:C语言实现学生成绩管理系统项目.doc
本文 PDF 下载地址:C语言实现学生成绩管理系统项目.pdf
留言与评论(共有 0 条评论) |