当前位置:网站首页>How to use C language nested linked list to realize student achievement management system
How to use C language nested linked list to realize student achievement management system
2022-07-26 16:41:00 【Yisu cloud】
How do you use it? C Language nested linked list to achieve student performance management system
This article “ How do you use it? C Language nested linked list to achieve student performance management system ” 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 “ How do you use it? C Language nested linked list to achieve student performance management system ” Article bar .
Linked list A, Each node stores a new linked list B1,B2,B3,B4,B5 Head node of . scene : A grade , Equivalent list A This grade 5 A class , Every class 5 personal , Equivalent to linked list B1--B5 Make a student achievement management system Students' grades are Chinese mathematics English function : Enter the score Find the highest score of the three subjects Lowest score Work out the average
Preface
Linked list is a common basic data structure , The structure pointer is fully utilized here .
The linked list can dynamically allocate storage , in other words , Linked list is a very powerful array , He can define multiple data types in the node , You can also add as you like , Delete , Insert node .
All linked lists have a head pointer , General with head To express , It's an address . There are two types of nodes in the list , Head node and general node , The header node has no data field . Each node in the list is divided into two parts , A data field , One is the pointer field .
You should have understood that , A list is like a car chain ,head Point to first element : The first element points to the second element ;……, Until the last element , This element no longer points to other elements , It's called “ Tail ”, Put a... In its address section “NULL”( Express “ Empty address ”), This is the end of the list .
As a powerful chain list , Of course, there are many operations on him , such as : Creation of linked list , modify , Delete , Insert , Output , Sort , trans , Empty the list of elements , Find the length of the list and so on .
C Language nested linked list to achieve student performance management system : Be familiar with the creation of linked lists , Use of structure pointer .
Realize the idea : Create student linked list -> Create a class list
among
The data field of the node of the student linked list stores the student's information ;
The data field of the node of the class chain is the pointer to the header node of the student chain ;
Using such a nested linked list to achieve multiple classes , And the performance management of multiple students in each class .
Tips : The following is the main body of this article , The following cases can be used for reference
One 、 Code implementation
1. Include header file
The code is as follows ( Example ):
#include<stdio.h>#include<stdlib.h>
2. Define the node of the student list
The code is as follows ( Example ):
struct Student // Declare the nodes of the student list { int chinese; int math; int english; int sum; struct Student* next;};3. Define the node of the class linked list
The code is as follows ( Example ):
struct Class// Declare the nodes of the class linked list { struct Student* student; struct Class* next;};4. Create a new node of the student list and insert it into the list by tail interpolation
The code is as follows ( Example ):
struct Student* CreateStudentNode(struct Student*head,int num)// Generate a new student node and insert it into the linked list by tail interpolation { struct Student* p=NULL; struct Student* node=(struct Student*)malloc(sizeof(struct Student));// Open up space for new nodes // Initialize new node node->next=NULL; printf(" Enter the first %d Student information :( Chinese language and literature mathematics English )\n",num+1); scanf("%d %d %d",&node->chinese,&node->math,&node->english); node->sum=node->chinese+node->math+node->english; if(head->next==NULL){ // When the linked list has only one node head->next=node; return head; } else{ // When the linked list has multiple nodes Put the pointer p Move to the end of the linked list p=head; while(p->next!=NULL){ p=p->next; } // Put the pointer p Move to the end of the linked list } p->next=node; return head;}5. Generate student linked list
The code is as follows ( Example ):
struct Student* init_StudentLink()// Generate student linked list { int sum,i; struct Student* head=(struct Student*)malloc(sizeof(struct Student));// Generate header node struct Student* p=NULL; scanf("%d",&sum);// Number of students for(i=0;i<sum;i++){ p=CreateStudentNode(head,i); } return p;}6. Create a new node of the class list and insert it into the list by tail interpolation
The code is as follows ( Example ):
struct Class* CreateClassNode(struct Class* head,int num)// Generate a new class node and insert it into the linked list by tail interpolation { struct Class* p=NULL; struct Class* node=(struct Class*)malloc(sizeof(struct Class)); node->next=NULL; struct Student* q=NULL; printf(" Enter the first %d The number of classes :\n",num+1); q=init_StudentLink(); node->student=q; if(head->next==NULL){ head->next=node; } else{ p=head; while(p->next!=NULL){ p=p->next; } } return 0;}7. Generate class linked list
The code is as follows ( Example ):
void init_Class(struct Class* head)// Generate class linked list { int sum,i; printf(" Please enter the number of classes established \n"); scanf("%d",&sum); for(i=0;i<sum;i++){ CreateClassNode(head,i); }}8. Print node information
The code is as follows ( Example ):
void printf_node(struct Class *head)// Print node information { int max,min; struct Class *q=NULL; struct Student *p=NULL; q=head->next; min=max=q->student->next->sum; printf("*****************************************************************************************************\n"); printf(" Score statistics \t( Chinese language and literature \t mathematics \t English \t Total score \t average )\n"); printf("*****************************************************************************************************\n"); int i=0,j=0; p=q->student->next; while(q){ i++; for(p;p->next!=NULL;p=p->next){ j++; printf(" The first %d Class %d Students' grades \n",i,j); printf(" Chinese language and literature :%d mathematics :%d English :%d Total score :%d average :%lf\n",p->chinese,p->math,p->english,p->sum,(double)(p->sum)/3); if(p->sum>max){ max=p->sum; } if(p->sum<min){ min=p->sum; } } printf("\n"); q=q->next; j=0; } printf(" The highest total score is :%d\n",max); printf(" The lowest total score is :%d\n",min);}9, The main function
The code is as follows ( Example ):
int main(){ struct Class* head=(struct Class*)malloc(sizeof(struct Class)); head->next=NULL;// Generate class head node init_Class(head);// Generate class linked list printf_node(head);// Print information return 0;}That's about “ How do you use it? C Language nested linked list to achieve student performance management system ” 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 .
边栏推荐
- The difference between oncreate and onrestoreinstancestate recovery data of activity
- Class initialization mechanism of JVM
- Compiler analysis of clojure operation principle
- FTP protocol
- Sharing of 40 completed projects of high-quality information management specialty [source code + Thesis] (VI)
- Pat grade a 1045 favorite color stripe
- Win11系统如何一键进行重装?
- Clojure operation principle bytecode generation
- [fluent -- advanced] packaging
- Pat grade a 1048 find coins
猜你喜欢

FTP protocol
![Sharing of 40 completed projects of high-quality information management specialty [source code + Thesis] (VI)](/img/b9/629449d3c946b017075ed42eaa81bf.png)
Sharing of 40 completed projects of high-quality information management specialty [source code + Thesis] (VI)

如何借助自动化工具落地DevOps|含低代码与DevOps应用实践

综合设计一个OPPE主页--导航栏的设计

2022-2023 topic recommendation of information management graduation project

Re7: reading papers fla/mlac learning to predict charges for critical cases with legal basis

Singleton mode

How to implement Devops with automation tools | including low code and Devops application practice

Linux安装mysql8.0.29详细教程

Re8:读论文 Hier-SPCNet: A Legal Statute Hierarchy-based Heterogeneous Network for Computing Legal Case
随机推荐
ACL-IJCAI-SIGIR顶级会议论文报告会(AIS 2022)笔记3:对话和生成
It turns out that cappuccino information security association does this. Let's have a look.
“青出于蓝胜于蓝”,为何藏宝计划(TPC)是持币生息最后的一朵白莲花
The "nuclear bomb level" log4j vulnerability is still widespread and has a continuing impact
Collection of open source expert opinions on trusted privacy computing framework "argot"
From SiCp to LISP video replay
C#转整型的三种方式的区别以及效率对比
The difference between oncreate and onrestoreinstancestate recovery data of activity
我的sql没问题为什么还是这么慢|MySQL加锁规则
怎么使用C语言嵌套链表实现学生成绩管理系统
Summary of key knowledge of C language
Matlab paper illustration drawing template issue 40 - pie chart with offset sector
vlang捣鼓之路
广东首例!广州一公司未履行数据安全保护义务被警方处罚
Digital currency of quantitative transactions - merge transaction by transaction data through timestamp and direction (large order consolidation)
别用Xshell了,试试这个更现代的终端连接工具
抓包与发流软件与网络诊断
Re7: reading papers fla/mlac learning to predict charges for critical cases with legal basis
C#事件和委托的区别
如何保证缓存和数据库一致性