網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
C語(yǔ)言實(shí)現(xiàn)學(xué)生成績(jī)管理系統(tǒng)課程設(shè)計(jì)_C 語(yǔ)言
作者:成就一億技術(shù)人 ? 更新時(shí)間: 2022-09-15 編程語(yǔ)言本文實(shí)例為大家分享了C語(yǔ)言實(shí)現(xiàn)學(xué)生成績(jī)管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
設(shè)計(jì)要求
設(shè)計(jì)學(xué)生成績(jī)管理系統(tǒng)
要求如下:
1.輸入學(xué)生信息
2.統(tǒng)計(jì)學(xué)生成績(jī)
3.查找并顯示學(xué)生成績(jī)
4.按姓名查找,修改學(xué)生資料
5.顯示所有學(xué)生名單
6.查找并刪除學(xué)生信息
7.輸出個(gè)科目成績(jī)最高的學(xué)生
完整代碼
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
struct Student
{
?? ?int cls;
?? ?char namee[10];
?? ?char number[10];
?? ?int chinese;
?? ?int english;
?? ?int computer;
?? ?int math;
}stud1[100];
int menu()
{
?? ?char a;
?? ?while(a>'8'||a<'0')
?? ?{
?? ??? ?system("cls");
?? ??? ?printf("***** ? ?學(xué)生成績(jī)管理系統(tǒng) ? ?*******\n");
?? ??? ?printf(" ? ? ? ? ? ? ?1.輸入學(xué)生信息\n");
?? ??? ?printf(" ? ? ? ? ? ? ?2.統(tǒng)計(jì)學(xué)生成績(jī)\n");
?? ??? ?printf(" ? ? ? ? ? ? ?3.查找并顯示學(xué)生成績(jī)\n");
?? ??? ?printf(" ? ? ? ? ? ? ?4.按姓名查找,修改學(xué)生資料\n");
?? ??? ?printf(" ? ? ? ? ? ? ?5.顯示所有學(xué)生名單\n");
?? ??? ?printf(" ? ? ? ? ? ? ?6.查找并刪除學(xué)生信息\n");
?? ??? ?printf(" ? ? ? ? ? ? ?7.輸出個(gè)科目成績(jī)最高的學(xué)生\n");
?? ??? ?printf(" ? ? ? ? ? ? ? 0.退出系統(tǒng)\n");
?? ??? ?printf("************************************\n");
?? ??? ?printf("請(qǐng)選擇(0-8)\n");
?? ??? ?a=getchar();//鍵盤(pán)敲的字符賦給a?
?? ?}
?? ?return(a-'0');
}
/******************************************/
int Input(Student stud[],int n) ? ? ?//輸入數(shù)據(jù) ? 定義輸入數(shù)據(jù)函數(shù)
{
?? ?int i=0;
?? ?char sign,x[10];
?? ?for(;sign !='n'&&sign !='N';)
?? ?{
?? ??? ?printf(" ? ? ? ? ? ? ? 姓名:");
?? ??? ?scanf("%s",stud[n+i].namee);
?? ??? ?printf(" ? ? ? ? ? ? ? 班級(jí):");
?? ??? ?scanf("%d",&stud[n+i].cls);
?? ??? ?printf(" ? ? ? ? ? ? ? 學(xué)號(hào):");
?? ??? ?scanf("%s",stud[n+i].number);
?? ??? ?printf(" ? ? ? ? ? ? ? 語(yǔ)文:");
?? ??? ?scanf("%d",&stud[n+i].chinese);
?? ??? ?printf(" ? ? ? ? ? ? ? 數(shù)學(xué):");
?? ??? ?scanf("%d",&stud[n+i].math);
?? ??? ?printf(" ? ? ? ? ? ? ? 英語(yǔ):");
?? ??? ?scanf("%d",&stud[n+i].english);
?? ??? ?printf(" ? ? ? ? ? ? ? 計(jì)算機(jī):");
?? ??? ?scanf("%d",&stud[n+i].computer);
?? ??? ?gets(x);
?? ??? ?printf("還有要輸入的信息嗎?(y/n)");
?? ??? ?scanf("%c",&sign);
?? ??? ?i++;
?? ?}
?? ?return(n+i);
}
void Sort(Student stud[], int n)//根據(jù)平均分排序(冒泡法)
{
?? ? int i,j;
? ? ?struct Student tmp;
? ? ?for (i=0;i<n;i++)
? ? ?{
? ? ? ? ?for (j=1;j<n-i;j++)
? ? ? ? ?{
? ? ? ? ? ? ? if ((stud[j-1].chinese+stud[j-1].english+stud[j-1].computer+stud[j-1].math)<(stud[j].chinese+stud[j].english+stud[j].computer+stud[j].math))
? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ?tmp=stud[j-1];
? ? ? ? ? ? ? ? ? ?stud[j-1]=stud[j];
? ? ? ? ? ? ? ? ? ?stud[j]=tmp;
? ? ? ? ? ? }
? ? ? ? ?}
? ? ?}
}?
/***************統(tǒng)計(jì)數(shù)據(jù)*******/
void Display(Student stud[], int n)
{
?? ?Sort(stud,n);
?? ?int i;
?? ?printf(" ? ? 班級(jí) ? ?學(xué)號(hào) ? ?姓名 ? 語(yǔ)文 ? ? 數(shù)學(xué) ? ?英語(yǔ) ? 計(jì)算機(jī) ? 總分 ? 平均分\n");
?? ?for(i=1;i<n+1;i++)
?? ?{ ??
?? ??? ?int s=stud[i-1].chinese+stud[i-1].math+stud[i-1].english+stud[i-1].computer;
?? ??? ?printf("%7d,%7s,%7s,%7d,%7d,%7d,%7d,%7d,%7d\n",stud[i-1].cls,stud[i-1].number,stud[i-1].namee,stud[i-1].chinese,stud[i-1].math,stud[i-1].english,stud[i-1].computer,s,s/4);
?? ??? ?if(i>1 && i%10==0)
?? ??? ?{
?? ??? ??? ?system("pause");
?? ??? ?}
?? ?}
?? ?system("pause");
?? ??? ?int a;
?? ?printf("語(yǔ)文不及格的有:班級(jí) ? ?姓名 ? 學(xué)號(hào) ? ?成績(jī)\n");?
?? ?for(a=0;a<n;a++)
?? ?{?
?? ??? ?if(stud[a].chinese<60)
?? ??? ?printf(" ? ? ? ? ? %7d %7s %7s% 7d\n",stud[a].cls,stud[a].namee,stud[a].number,stud[a].chinese);
?? ? }?
?? ?printf("數(shù)學(xué)不及格的有:班級(jí) ? ?姓名 ? 學(xué)號(hào) ? ?成績(jī)\n");?
?? ?for(a=0;a<n;a++)
?? ?{?
?? ??? ?if(stud[a].math<60)
?? ?printf(" ? %7d %7s %7s %7d\n",stud[a].cls,stud[a].namee,stud[a].number,stud[a].math);
?? ? }?
?? ?printf("英語(yǔ)不及格的有:班級(jí) ? ?姓名 ? 學(xué)號(hào) ? ?成績(jī)\n");
?? ?for(a=0;a<n;a++)
?? ?{?
?? ??? ?if(stud[a].english<60)
?? ?printf(" ? ? ? ? ? %7d %7s %7s %7d\n",stud[a].cls,stud[a].namee,stud[a].number,stud[a].english);
?? ? }?
?? ?printf("計(jì)算機(jī)不及格的有:班級(jí) ? ?姓名 ? 學(xué)號(hào) ? ?成績(jī)\n");?
?? ?for(a=0;a<n;a++)
?? ?{?
?? ??? ?if(stud[a].computer<60)
?? ?printf(" ? ? ? ? ? ?%7d %7s %7s %7d\n",stud[a].cls,stud[a].namee,stud[a].number,stud[a].computer);
?? ? }?
?? ? system("pause");
}
/************查找學(xué)生顯示其信息*******************/
void Query(Student stud[],int n)
{
?? ?char namee[20];
?? ?printf(" ? ? ? ? ?輸入其姓名:\n");
? ? scanf("%s",namee);
?? ?int i=0;
?? ?while(strcmp(stud[i].namee,namee)!=0&&i<n)
?? ??? ?i++;
?? ?if(i==n)
?? ?{
?? ??? ?printf("\t\t\t沒(méi)有發(fā)現(xiàn)該學(xué)生的資料!\n");
?? ??? ?return;
?? ?}
?? ?printf(" ? ? ? ? ?學(xué)號(hào):%s\n",stud[i].number);
?? ?printf(" ? ? ? ? ?班級(jí):%d\n",stud[i].cls);
?? ?printf(" ? ? ? ? ?語(yǔ)文:%d\n",stud[i].chinese);
?? ?printf(" ? ? ? ? ?英語(yǔ):%d\n",stud[i].english);
?? ?printf(" ? ? ? ? ?數(shù)學(xué):%d\n",stud[i].math);
?? ?printf(" ? ? ? ? ?計(jì)算機(jī):%d\n",stud[i].computer);
}
/************刪除學(xué)生信息*********/
int Delete(Student stud[],int n)
{
?? ?char s[20];
?? ?int i=0,j;
?? ?printf(" ? ? ? 請(qǐng)輸入要?jiǎng)h除的學(xué)生的姓名:\n");
?? ?scanf("%s",s);
?? ?while(strcmp(stud[i].namee,s)!=0&&i<n) i++;?
?? ?if(i==n)?
?? ?{
?? ??? ?printf("\t\t\t沒(méi)有發(fā)現(xiàn)該學(xué)生資料!\n");
?? ??? ?return(n);?
?? ?}?
?? ?for(j=i;j<n-1;j++)?
?? ?{?
?? ??? ?strcpy(stud[j].number,stud[j+1].number);
?? ??? ?strcpy(stud[j].namee,stud[j+1].namee);?
?? ??? ?stud[j].cls=stud[j+1].cls;
?? ??? ?stud[j].chinese=stud[j+1].chinese;
?? ??? ?stud[j].math=stud[j+1].math;
?? ??? ?stud[j].english=stud[j+1].english;?
?? ??? ?stud[j].computer=stud[j+1].computer;
?? ?}?
?? ?printf(" ? ? ? ? ?當(dāng)前信息已刪除成功!");?
?? ?return(n-1);?
}
/****************修改信息**********************/
int Revise(Student stud[],int n)
{
?? ?int i=0;
?? ?char na[10];
?? ?scanf("%s",na);
?? ?while(strcmp(stud[i].namee,na)!=0&&i<n)
?? ??? ?i++;
?? ?if(i==n)
?? ?{
?? ??? ?printf("\t\t\t沒(méi)有發(fā)現(xiàn)該學(xué)生的資料!\n");
?? ?}
?? ?printf("修改班級(jí):\n");
?? ?scanf("%d",&stud[i].cls);
?? ?printf("修改學(xué)號(hào):\n");
?? ?scanf("%s",stud[i].number);
?? ?printf("修改語(yǔ)文成績(jī):\n");
?? ?scanf("%d",&stud[i].chinese);
?? ?printf("修改英語(yǔ)成績(jī):\n");
?? ?scanf("%d",&stud[i].english);
?? ?printf("修改數(shù)學(xué)成績(jī):\n");
?? ?scanf("%d",&stud[i].math);
?? ?printf("修改計(jì)算機(jī)成績(jī):\n");
?? ?scanf("%d",&stud[i].computer);
?? ?printf("修改成功\n");
?? ?return(n);
}
/***************************************顯示學(xué)生名單**************************************/
void show(Student stud[],int n)
{
? ? for(int i=0;i<n;i++)
?? ?{
?? ??? ?printf(" ? ?%s\n",stud[i].namee);
?? ?}
?? ?system("pause");
}
//
void SercherH(Student stud[],int n)//搜索成績(jī)最高者輸出?
{
?? ?int a;
?? ?int max ;
?? ?printf("語(yǔ)文成績(jī)最高為:班級(jí) ? ?姓名 ? 學(xué)號(hào) ? ?成績(jī)\n");?
?? ?max=stud[0].chinese;
?? ?for(a=1;a<n;a++)
?? ?{?
?? ??? ?if(stud[a].chinese>max)
?? ??? ?max=stud[a].chinese;
?? ?}
?? ?for(a=0;a<n;a++)
?? ?{?
?? ??? ?if(max==stud[a].chinese)
?? ??? ?printf(" ? ? ? ? ? %7d %7s %7s% 7d\n",stud[a].cls,stud[a].namee,stud[a].number,stud[a].chinese);
?? ?}
?? ?printf("數(shù)學(xué)成績(jī)最高為:班級(jí) ? ?姓名 ? 學(xué)號(hào) ? ?成績(jī)\n");?
?? ?max=stud[0].math;
?? ?for(a=1;a<n;a++)
?? ?{?
?? ??? ?if(stud[a].math>max)
?? ??? ?max=stud[a].math;
?? ?}
?? ?for(a=0;a<n;a++)
?? ?{?
?? ??? ?if(max==stud[a].math)
?? ??? ?printf(" ? ? ? ? ? %7d %7s %7s% 7d\n",stud[a].cls,stud[a].namee,stud[a].number,stud[a].math);
?? ?}
?? ?printf("英語(yǔ)成績(jī)最高為:班級(jí) ? ?姓名 ? 學(xué)號(hào) ? ?成績(jī)\n");?
?? ?max=stud[0].english;?
?? ?for(a=1;a<n;a++)
?? ?{?
?? ??? ?if(stud[a].english>max)
?? ??? ?max=stud[a].english;
?? ?}
?? ?for(a=0;a<n;a++)
?? ?{?
?? ??? ?if(max==stud[a].english)
?? ??? ?printf(" ? ? ? ? ? %7d %7s %7s% 7d\n",stud[a].cls,stud[a].namee,stud[a].number,stud[a].english);
?? ?}
?? ?printf("計(jì)算機(jī)成績(jī)最高為:班級(jí) ? ?姓名 ? 學(xué)號(hào) ? ?成績(jī)\n");?
?? ?max=stud[0].computer;
?? ?for(a=1;a<n;a++){?
?? ??? ?if(stud[a].computer>max)
?? ??? ?max=stud[a].computer;}
?? ?for(a=0;a<n;a++)?? ?{?
?? ??? ?if(max==stud[a].computer)
?? ??? ?printf(" ? ? ? ? ? %7d %7s %7s% 7d\n",stud[a].cls,stud[a].namee,stud[a].number,stud[a].computer);}
?? ? system("pause");}
/*****************主函數(shù)調(diào)用*****************/
int main()
{
?? ?int n1=0;
?? ?for(;;)
?? ?{
?? ??? ?switch(menu()){
?? ??? ?case 1:
?? ??? ??? ?printf(" ? ? ? ? ? ? ? 輸入學(xué)生資料\n");
?? ??? ??? ?n1=Input(stud1,n1);break;
?? ??? ?case 2:
?? ??? ??? ?printf(" ? ? ? ? ? ? ? ? ?輸出所有學(xué)生資料\n");
?? ??? ??? ??? ?Display(stud1,n1);break;
?? ??? ?case 3:
?? ??? ??? ?int r;printf(" ? ? ? ? ? ? ? 查找學(xué)生\n");
?? ??? ??? ?Query(stud1,n1);
system("pause");break;
?? ??? ?case 4:
?? ??? ??? ?int p;printf(" ? ? ? ? ? ? ? 修改學(xué)生資料\n");
printf(" ? ? ? ? ? ? ? 輸入你要修改的學(xué)生的姓名:");
?? ??? ??? ??? ?n1=Revise(stud1,n1);
?? ??? ??? ?system("pause");break;
?? ??? ?case 5:
?? ??? ??? ?printf(" ? ? ? ? ? ? ? 顯示所有學(xué)生名單:\n");
?? ??? ??? ??? ?show(stud1,n1);
?? ??? ??? ?system("pause");break;
? ? ? ? case 6:
?? ??? ??? ?printf(" ? ? ? ? ? ? ? 查找并刪除學(xué)生信息\n");
?? ??? ??? ?int o;
n1=Delete(stud1,n1);
system("pause");break;
?? ??? ?case 7:
?? ??? ??? ?int l;SercherH(stud1,n1);break;?? ?
?? ??? ?case 0:?? ??? ??? ??? ?
?? ??? ??? ?system("pause");break;
?? ??? ?}
?? ?}
}
運(yùn)行結(jié)果
后面的需要執(zhí)行哪項(xiàng)功能,就輸入對(duì)應(yīng)數(shù)字就可以!
原文鏈接:https://blog.csdn.net/weixin_55764157/article/details/122239825
相關(guān)推薦
- 2022-06-01 Android中的Coroutine協(xié)程原理解析_Android
- 2022-05-16 docker的具名掛載與匿名掛載實(shí)現(xiàn)_docker
- 2022-09-03 C++中std::conditional的使用說(shuō)明_C 語(yǔ)言
- 2023-07-10 VMware三種網(wǎng)絡(luò)模式配置詳解。
- 2022-06-10 SQL?Server使用導(dǎo)出向?qū)Чδ躝MsSql
- 2022-04-02 一文講解Kotlin中的contract到底有什么用_Android
- 2022-09-19 Nginx最大連接數(shù)配置詳解_nginx
- 2022-03-15 eclipse文件上傳錯(cuò)誤:the request doesn‘t contain a multip
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門(mén)
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支