当前位置:网站首页>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;
}
}
}
边栏推荐
猜你喜欢
![[ansible series] fundamentals -01](/img/b4/1f3284338c75acb5259849a45bbfbe.jpg)
[ansible series] fundamentals -01

Dao -- a beautiful new world?

Swoole process model diagram

Installation and initialization of MariaDB database

Usage of case, casez and casex statements in Verilog

Gestion des utilisateurs de la base de données MySQL

leetcode763. Divide letter interval

Application of redis client list in practice

Tornado frame foundation

Intelligent deodorizer embedded development
随机推荐
Cisco vxlan configuration
二十四、输入输出设备模型(串口/键盘/磁盘/打印机/总线/中断控制器/DMA和GPU)
Win10 /11 开热点无法上网问题
Balanced binary tree judgment of Li Kou 110 -- classic problems
Go pack and unpack
ES6解构赋值
重构之美:当多线程批处理任务挑起大梁 - 万能脚手架
ES6箭头函数
Network basics
[Alibaba cloud] student growth plan answers
[MD editing required] welcome to the CSDN markdown editor
[deep learning] data segmentation
Es6数组
Usage of case, casez and casex statements in Verilog
How to use unmarshaljson
谁不想要一个自己的博客网站呢 - 搭建博客网站wordpress
MySQL log management, data backup and recovery
MySQL 索引
【微信小程序:单选、多选样式,背景色,圆角】
Voting vault: a new primitive for defi and Governance