当前位置:网站首页>C language final experiment report (student achievement management system) source code
C language final experiment report (student achievement management system) source code
2022-06-30 06:11:00 【Inflamed shellfish】
university C Language final comprehensive experiment report source code
Student achievement management system
- Compile and run the following source code .
- Wait a few seconds to display the operation window interface .

- Input 1 And then go back , Create a linked list . Enter the number of students in turn , Student number , full name , Grades in various subjects, etc . After input, press any key to end . Here's the picture .

- Input 3 And then go back . Save the file . Display saved successfully . Press any key to end . Here's the picture

- Input 2 enter , View the data . Here's the picture .

- Input 5 enter , Exit the system .

Source code is as follows
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
int num;
struct xs
{
int xh;
char xm[20];
int gs,yy,wl;
double pj;
struct xs *next;
};
struct xs *create()
{
int i;
struct xs *p=NULL,*hd=(struct xs *)malloc(sizeof(struct xs));
hd->next=NULL;
printf(" Please input the number of students :");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
p=(struct xs *)malloc(sizeof(struct xs));
printf(" Please enter the first %d A student %d-%d\n",i,num,i);
printf(" Student number :");
scanf("%d",&p->xh);
printf(" full name :");
scanf("%s",p->xm);
printf(" Advanced Mathematics :");
scanf("%d",&p->gs);
printf(" English :");
scanf("%d",&p->yy);
printf(" Physics :");
scanf("%d",&p->wl);
p->pj=(p->gs+p->yy+p->wl)/3.0;
p->next=hd->next;
hd->next=p;
}
printf(" End of creation , Please press any key to end !\n");
getch();
return hd;
}
void print(struct xs *hd)
{
if(hd==NULL)
{
printf(" Linked list is empty. , Please create the linked list or read the file first , Press any key to continue !\n");
getch();
}
else
{
struct xs *p=hd->next;
printf("*********************************************************\n");
printf(" Student number full name Advanced Mathematics English Physics Average \n");
printf("*********************************************************\n");
while(p!=NULL)
{
printf("%4d %-6s %5d %5d %5d %5.2f\n",p->xh,p->xm,p->gs,p->yy,p->wl,p->pj);
p=p->next;
}
printf("*********************************************************\n");
printf(" Show end , Please press any key to continue !\n");
getch();
}
}
void sf(struct xs *hd)
{
if(hd!=NULL)
{
struct xs *p=hd->next;
while(p!=NULL)
{
hd->next=p->next;
free(p);
p=hd->next;
}
free(hd);
}
}
void save(struct xs *hd)
{
if(hd==NULL)
{
printf(" Linked list is empty. , Unable to save file , Please press any key to continue !\n");
getch();
}
else
{
FILE *fp=fopen("1.txt","w");
struct xs *p=hd->next;
fprintf(fp,"%d\n",num);
while(p!=NULL)
{
fprintf(fp,"%d %s %d %d %d %lf\n",p->xh,p->xm,p->gs,p->yy,p->wl,p->pj);
p=p->next;
}
fclose(fp);
printf(" End of linked list saving , Please press any key to continue !\n");
getch();
}
}
struct xs *read()
{
FILE *fp=fopen("1.txt","r");
if(fp!=NULL)
{
int rs,i;
struct xs *p=NULL,*hd=(struct xs *)malloc(sizeof(struct xs));
hd->next=NULL;
fscanf(fp,"%d\n",&rs);
for(i=1;i<=rs;i++)
{
p=(struct xs *)malloc(sizeof(struct xs));
fscanf(fp,"%d %s %d %d %d %lf\n",&p->xh,p->xm,&p->gs,&p->yy,&p->wl,&p->pj);
p->next=hd->next;
hd->next=p;
}
fclose(fp);
printf(" End of file read , Please press any key to continue !\n");
getch();
return hd;
}
else
{
printf(" No data files , Please save the file first , Press any key to continue !\n");
getch();
return NULL;
}
}
void menu()
{
system("cls");
printf("*****************************************\n");
printf("* Student management system (1.0) *\n");
printf("*****************************************\n");
printf("* *\n");
printf("*****************************************\n");
printf("** 1- Create a linked list **\n");
printf("** 2- data display **\n");
printf("** 3- Save the file **\n");
printf("** 4- Read the file **\n");
printf("** 5- System exit **\n");
printf("*****************************************\n");
printf("** Please select action (1-5) **\n");
printf("*****************************************\n");
}
void main()
{
struct xs *head=NULL;
int xz=0;
while(xz!=5)
{
menu();
scanf("%d",&xz);
switch(xz)
{
case 1:sf(head);head=create();break;
case 2:print(head);break;
case 3:save(head);break;
case 4:sf(head);head=read();break;
case 5:sf(head);break;
}
}
}
边栏推荐
- InputStream to inputstreamsource
- SHELL
- To: k210 realizes face recognition (code interpretation attached)
- ES6 arrow function
- ES6 deconstruction assignment
- Title: enter two positive integers m and N to find their maximum common divisor and minimum common multiple
- Luogup2756 pilot pairing scheme problem (maximum flow)
- Learn fpga---ram IP core and key parameters from the bottom structure
- C language code record
- 46. 全排列-dfs双百代码
猜你喜欢

Intelligent question - horse racing question

Base64 explanation: playing with pictures Base64 encoding

Mysql database user management

Detailed description of methods in the interface

关于Glide加载图片模糊不清楚

从底层结构开始学习FPGA----RAM IP核及关键参数介绍

One sentence introduction to Trojan horse

MySQL事物

MySQL advanced SQL statement

Installation and initialization of MariaDB database
随机推荐
电脑查看WiFi使用密码
Summary of redis learning notes (I)
VIM view file code
重构之美:当多线程批处理任务挑起大梁 - 万能脚手架
Leetcode search insert location
MySQL事物
Is it safe to open an account online? Can you open an account to speculate on the Internet?
SparseArray
MySQL advanced SQL statement
Common mistakes daily practice 01
Potential bottleneck of redis
Altium designer creates multiple class networks to realize different lineweights of multiple networks
01. regular expression overview
STM32F103 series controlled OLED IIC 4-pin
Intelligent question - horse racing question
RSA and AES
PC viewing WiFi password
从底层结构开始学习FPGA----RAM IP核及关键参数介绍
MySQL summary
Win10 /11 开热点无法上网问题