当前位置:网站首页>The method of implementing simple student achievement management system with C language
The method of implementing simple student achievement management system with C language
2022-07-28 14:35:00 【Yisu cloud】
C The method of realizing simple student achievement management system with language
This article “C The method of realizing simple student achievement management system with language ” Most people don't quite understand the knowledge points of the article , So I made up the following summary for you , Detailed content , The steps are clear , It has certain reference value , I hope you can gain something after reading this article , Let's take a look at this article “C The method of realizing simple student achievement management system with language ” Article bar .
System interface and related requirements
1) System operation , Open the following interface . List the system help menu ( Command menu ), Prompt for commands .

2) You haven't entered your grades at the beginning , So enter the command L And I can't list my grades . Should prompt “ The grade sheet is empty ! Please use the command first T Enter student scores .”
Empathy , When inputting other grade processing commands, it will also be processed accordingly .

3) Enter the command T, call Type Sub function entry score .
The interface prompts you to enter the number of students
Input 3 prompt 3 Students 3 Course results , List the header of the transcript “ Student number Chinese language and literature mathematics English ”, Prompt student number :1
Input 1 Student No 3 Course results , Use space between , End of carriage return . Prompt student number :2
Input 2 Student No 3 Course results , Use space between , End of carriage return . Prompt student number :3
Input 3 Student No 3 Course results , Use space between , End of carriage return .Type End of subfunction call , return . Prompt for commands .

4) Enter the command L , call List Sub function output score table .List End of subfunction call , return . Prompt for commands .

5) Enter the command A , call Average The subfunction calculates the average score , Tips “ The average score has been calculated . Please use the command L see .” Average End of subfunction call , return . Prompt for commands .
Enter the command L , call List Sub function output score table .List End of subfunction call , return . Prompt for commands .

6) Enter the command P , call Sort The sub function sorts the student records from high to low according to the average score , Tips “ To complete the order . Please use the command L see .” Sort End of subfunction call , return . Prompt for commands .
Enter the command L , call List Sub function output score table .List End of subfunction call , return . Prompt for commands .

7) Enter the command S , call Search Sub function queries student grades , Tips “ Enter the student number to query ”.
Input 2 find 2 Student No. and output .Search End of subfunction call , return . Prompt for commands .

8) Enter the command C Execute the clear screen function statement system(“clear”);
Clear everything on the screen . Prompt for commands .


9) Enter the command H call Help The sub function displays the help menu .Help End of subfunction call , return . Prompt for commands .

10) Enter the command Q , Exit the system .

Be careful :
1) When outputting array elements , The student number should be handled separately , The output is an integer ( Namely reservation 0 Decimal place ). Empathy , When calculating grades, you should also put the number 1 Put aside the student number in the column , Only the second 2 After column . Achievement retention 1 Decimal place .
2) Number of students n Throughout , adopt n The value of determines whether the sub function of the current command can be called and executed . for example : When n=0 when , Note that the score has not been entered . And once you enter a command T, That is to call Type The sub function has entered the score , be n The value of is no longer 0. When n!=0 when , You can perform other performance operations , But you can no longer perform the operation of employment results . So when the command entered by the user cannot be executed , Prompt should be given .
Code
#include <stdio.h>#include <stdlib.h>//#include "hs.h"struct student{ int id; float yw; float sx; float wy; float pj;};void help(void);int type(struct student *p);void list(struct student *p,int n);void average(struct student *p,int n);void search (struct student *p);void sort(struct student *p,int n);int main(int argc, const char *argv[]){ char ch; struct student stu[32]; int n=0; while(1) { printf(" Please enter a command = "); //getchar(); scanf("%c",&ch); putchar(10); if(ch=='T') { n=type(stu); } else if(ch=='L') { if(n==0) { printf(" The grade sheet is empty ! Please use first. T Enter the score !\n"); putchar(10); } else list(stu,n); } else if(ch=='A') { if(n==0) { printf(" The grade sheet is empty ! Please use first. T Enter the score !\n"); putchar(10); } else { average(stu,n); printf(" The average score has been calculated , Please use the command L see !\n"); putchar(10); } } else if(ch=='H') help(); else if(ch=='C') system("clear"); else if(ch=='S') { if(n==0) { printf(" The grade sheet is empty ! Please use first. T Enter the score !\n"); putchar(10); } else { search(stu); putchar(10); } } else if(ch=='P') { if(n==0) { printf(" The grade sheet is empty ! Please use first. T Enter the score !\n"); putchar(10); } else { sort(stu,n); putchar(10); } } else if(ch=='Q') { printf("Press any key to continue!\n"); return -1; } getchar(); } return 0;}int type(struct student *p){ int n=0; printf(" Please input the number of students :"); scanf("%d",&n); printf(" Please enter the student's grades in three courses :\n"); printf(" Student number Chinese language and literature mathematics Foreign Languages \n"); for(int i=0;i<n;i++) { printf("%d ",i+1); struct student stu[i]; scanf("%f %f %f",&(p+i)->yw,&(p+i)->sx,&(p+i)->wy); } return n;}void list(struct student *p,int n){ printf(" The students' grades are as follows :\n"); printf(" Student number Chinese language and literature mathematics Foreign Languages average \n"); for(int i=0;i<n;i++) { printf("%d ",i+1); printf("%.1f %.1f %.1f %.1f",p->yw,p->sx,p->wy,p->pj); p++; putchar(10); }}void average(struct student *p,int n){ for(int i=0;i<n;i++) { (p->pj)=((p->yw)+(p->sx)+(p->wy))/3; p++; }}void help(void){ printf("**********************************\n"); printf(" * Student achievement management system —— In the help menu * \n"); printf("**********************************\n"); printf(" * H = Show help menu * \n"); printf(" * T = Score entry * \n"); printf(" * A = Calculate the student average * \n"); printf(" * L = List the transcript * \n"); printf(" * P = Sort by GPA from high to low * \n"); printf(" * S = Inquire the student's grade by student number * \n"); printf(" * C = Clear the screen * \n"); printf(" * Q = Exit the system * \n"); printf("**********************************\n"); printf(" *Copyright(c) 2022.3.15 By liq* \n"); printf("**********************************\n");}void search(struct student *p){ int s=0; printf(" Please enter the student number to be queried :"); scanf("%d",&s); printf(" Student number Chinese language and literature mathematics Foreign Languages average \n"); printf("%d %.1f %.1f %.1f %.1f",s,(p+s-1)->yw,(p+s-1)->sx,(p+s-1)->wy,(p+s-1)->pj); putchar(10);}void sort(struct student *p,int n){ struct student temp; int i,j; for(i=0;i<n;i++) { for(j=0;j<n-i-1;j++) { if(p[j].pj<p[j+1].pj) { temp=p[j]; p[j]=p[j+1]; p[j+1]=temp; } } } printf(" Sort complete , Please use the command L see !\n");}Be careful
If it needs to be written in separate documents .
Just take out the function part of the above code , Create two new files :fun.c、fun.h. among fun.c File is used to store the structure declaration and function part of the above code ( Add the corresponding header file ).fun.h Used to store structure declaration and function declaration ( Add the corresponding header file ).
Add the corresponding header file to the main function :#include “fun.h”( Double quotes , No <>).
When compiling, the main function and the newly created fun.c Compile files together , The operation is the same as before , use ./a.out Can run .
The details are shown in the following figure :
1. Create two new files ( The same name , Different suffixes ), Compile and run ( You need to compile multiple files at the same time ).

2.hs.c Store the structure declaration and the corresponding function ( The functions in this can also be split into other files , I won't split it here ).
#include <stdio.h>#include <stdlib.h>struct student{ int id; float yw; float sx; float wy; float pj;};int type(struct student *p){ int n=0; printf(" Please input the number of students :"); scanf("%d",&n); putchar(10); printf(" Please enter the student's grades in three courses :\n"); putchar(10); printf(" Student number Chinese language and literature mathematics Foreign Languages \n"); for(int i=0;i<n;i++) { printf("%d ",i+1); struct student stu[i]; scanf("%f %f %f",&(p+i)->yw,&(p+i)->sx,&(p+i)->wy); } putchar(10); return n;}void list(struct student *p,int n){ printf(" The students' grades are as follows :\n"); printf(" Student number Chinese language and literature mathematics Foreign Languages average \n"); for(int i=0;i<n;i++) { printf("%d ",i+1); printf("%.1f %.1f %.1f %.1f",p->yw,p->sx,p->wy,p->pj); p++; putchar(10); } putchar(10);}void average(struct student *p,int n){ for(int i=0;i<n;i++) { (p->pj)=((p->yw)+(p->sx)+(p->wy))/3; p++; }}void help(void){ printf("**********************************\n"); printf(" * Student achievement management system —— In the help menu * \n"); printf("**********************************\n"); printf(" * H = Show help menu * \n"); printf(" * T = Score entry * \n"); printf(" * A = Calculate the student average * \n"); printf(" * L = List the transcript * \n"); printf(" * P = Sort by GPA from high to low * \n"); printf(" * S = Inquire the student's grade by student number * \n"); printf(" * C = Clear the screen * \n"); printf(" * Q = Exit the system * \n"); printf("**********************************\n"); printf(" *Copyright(c) 2022.3.15 By liq* \n"); printf("**********************************\n");}void search(struct student *p){ int s=0; printf(" Please enter the student number to be queried :"); scanf("%d",&s); putchar(10); printf(" Student number Chinese language and literature mathematics Foreign Languages average \n"); printf("%d %.1f %.1f %.1f %.1f",s,(p+s-1)->yw,(p+s-1)->sx,(p+s-1)->wy,(p+s-1)->pj); putchar(10);}void sort(struct student *p,int n){ struct student temp; int i,j; for(i=0;i<n;i++) { for(j=0;j<n-i-1;j++) { if(p[j].pj<p[j+1].pj) { temp=p[j]; p[j]=p[j+1]; p[j+1]=temp; } } } printf(" Sort complete , Please use the command L see !\n");}3.hs.h Storage structure declaration and hs.c The function declaration corresponding to the function inside .
#include <stdio.h>#include <stdlib.h>struct student{ int id; float yw; float sx; float wy; float pj;};int type(struct student *p);void list(struct student *p,int n);void average(struct student *p,int n);void help(void);void search(struct student *p);void sort(struct student *p,int n);4.main function
#include <stdio.h>#include <stdlib.h>#include "hs.h"int main(int argc, const char *argv[]){ char ch; struct student stu[32]; int n=0; while(1) { printf(" Please enter a command = "); scanf("%c",&ch); putchar(10); if(ch=='T') { n=type(stu); } else if(ch=='L') { if(n==0) { printf(" The grade sheet is empty ! Please use first. T Enter the score !\n"); putchar(10); } else list(stu,n); } else if(ch=='A') { if(n==0) { printf(" The grade sheet is empty ! Please use first. T Enter the score !\n"); putchar(10); } else { average(stu,n); printf(" The average score has been calculated , Please use the command L see !\n"); putchar(10); } } else if(ch=='H') help(); else if(ch=='C') system("clear"); else if(ch=='S') { if(n==0) { printf(" The grade sheet is empty ! Please use first. T Enter the score !\n"); putchar(10); } else { search(stu); putchar(10); } } else if(ch=='P') { if(n==0) { printf(" The grade sheet is empty ! Please use first. T Enter the score !\n"); putchar(10); } else { sort(stu,n); putchar(10); } } else if(ch=='Q') { printf("Press any key to continue!\n"); return -1; } getchar(); } return 0;}That's about “C The method of realizing simple student achievement management system with language ” The content of this article , I believe we all have a certain understanding , I hope the content shared by Xiaobian will be helpful to you , If you want to know more about it , Please pay attention to the Yisu cloud industry information channel .
边栏推荐
- Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it
- C语言实现简单学生成绩管理系统的方法
- MySQL development skills - View
- @Solution to DS ('slave') multi data source compatible transaction problem
- OKR and grad
- 3种方法解轮转数组
- These three online PS tools should be tried
- 八、picker用法 下拉框选择效果
- Forage QR code -- online QR code generator
- AFNetworking速成教程
猜你喜欢
![[ecmascript6] set and map](/img/64/dd6ffc5f0faf881b990e609cf62343.png)
[ecmascript6] set and map

ZABBIX distributed

MiniTest--小程序自动化测试框架

MySQL development skills - View

Thesis study -- masked generative disintegration

软件测试的发展与定义

HCIP第十天

Foundation of deep learning ---- GNN spectral domain and airspace (continuous improvement, update and accumulation)
![[server data recovery] HP StorageWorks series server RAID5 offline data recovery of two disks](/img/23/4d07adcb5fb2c3b4c5090dacd02c89.jpg)
[server data recovery] HP StorageWorks series server RAID5 offline data recovery of two disks

复制excel行到指定行
随机推荐
2022 safety officer-a certificate operation certificate examination question bank simulated examination platform operation
一些企业数据平台建设的思考
为自定义属性包装类型添加类 @Published 的能力
成为绿色数据中心新样板,东莞华为云数据中心是怎样炼成的?
UFIDA BiP CRM new product launch enables large and medium-sized enterprises to grow their marketing
Brief introduction of diversity technology
用友BIP CRM新品发布,赋能大中型企业营销增长
@DS('slave') 多数据源兼容事务问题解决方案
天气这么热太阳能发电不得起飞喽啊?喽啊个头……
Install mysql5.7.36 in CentOS
十、时间戳
It's so hot that solar power can't take off? Hello, head
What is gossip (E-Net gossip)
Development and definition of software testing
Pointers and arrays (7)
如何只降3D相机不降UI相机的分辨率
[ecmascript6] set and map
企鹅一面:为什么不建议使用SELECT * ?
Analysis of thrift serialization protocol
Foundation of deep learning ---- GNN spectral domain and airspace (continuous improvement, update and accumulation)