当前位置:网站首页>C student management system head to add a student node
C student management system head to add a student node
2022-08-05 02:18:00 【joker_0030】
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
//学生节点.
typedef struct _STU
{
char arrStuNum[10];
char arrStuName[10];
int iStuScore;
struct _STU* pNext;//指向下一个节点.
}STUNODE;
//Declare the head and tail of the linked list.
STUNODE* g_pHead = NULL;
STUNODE* g_pEnd = NULL;
//Add information to the header of the linked list.
void AddStuMSGToLinkHead(char* arrStuNum[10], char arrStuName[10], int iStuScore);
int main()
{
int nOrder = -1;
char arrStuNum[10] = { '\0' };
char arrStuName[10] = { '\0' };
int iStuScore = -1;
int nFlag = 1;
//显示指令.
ShowOrder();
while (nFlag)
{
printf("请输入操作指令(0for viewing instructions)\n");
scanf("%d", &nOrder);
switch (nOrder)
{
case 1://添加一个学生信息.
printf("输入学号:");
scanf("%s", arrStuNum);
printf("输入姓名:");
scanf("%s", arrStuName);
printf("输入分数:");
scanf("%d", &iStuScore);//取地址.
AddStuMSG(arrStuNum, arrStuName, iStuScore);
break;
case 10://头添加.
printf("输入学号:");
scanf("%s", arrStuNum);
printf("输入姓名:");
scanf("%s", arrStuName);
printf("输入分数:");
scanf("%d", &iStuScore);//取地址.
AddStuMSGToLinkHead(arrStuNum, arrStuName, iStuScore);
break;
case 2:
printf("请输入学生学号/姓名");
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8://打印数据(链表).
ShowStuData();
break;
case 9:
nFlag = 0;
break;
case 0:
//查看指令.
ShowOrder();
break;
default:
printf("输入的指令不对");
break;
}
}
//释放链表.
FreeLinkData();
system("pause");
return 0;
}
//Add information to the header of the linked list.
void AddStuMSGToLinkHead(char* arrStuNum[10], char arrStuName[10], int iStuScore)
{
//检测参数的合法性.
if (NULL == arrStuNum || NULL == arrStuName || iStuScore < 0)
{
printf("学生信息输入错误.\n");
return;
}
//创建一个节点.
STUNODE* pTemp = malloc(sizeof(STUNODE));
//成员赋值.
strcpy(pTemp->arrStuNum, arrStuNum);//Because the array is completely a pointer when it is passed in as a parameter.
strcpy(pTemp->arrStuName, arrStuName);//Because the array is completely a pointer when it is passed in as a parameter.
pTemp->iStuScore = iStuScore;
pTemp->pNext = NULL;
if (NULL == g_pHead || NULL == g_pEnd)
{
//链表为空.
g_pHead = pTemp;
g_pEnd = pTemp;
}
else
{
//The next point of the new node points to the head.
pTemp->pNext = g_pHead;
//向前移动一个.
g_pHead = pTemp;
}
}
边栏推荐
- Domain Driven Design - MDD
- 迁移学习——Distant Domain Transfer Learning
- nodeJs--封装路由
- C语言实现简单猜数字游戏
- Programmer's list of sheep counting when insomnia | Daily anecdote
- 刷爆朋友圈,Alibaba出品亿级并发设计速成笔记太香了
- 多线程(2)
- Live playback including PPT download | Build Online Deep Learning based on Flink & DeepRec
- LPQ (local phase quantization) study notes
- Transfer Learning - Distant Domain Transfer Learning
猜你喜欢

Flink 1.15.1 集群搭建(StandaloneSession)

记录谷歌gn编译时碰到的一个错误“I could not find a “.gn“ file ...”

DAY23: Command Execution & Code Execution Vulnerability

树形查找(二叉查找树)

Understand the recommendation system in one article: Recall 06: Two-tower model - model structure, training method, the recall model is a late fusion feature, and the sorting model is an early fusion

Simple implementation of YOLOv7 pre-training model deployment based on OpenVINO toolkit

Advanced Numbers_Review_Chapter 1: Functions, Limits, Continuity

学习笔记-----左偏树

LeetCode使用最小花费爬楼梯----dp问题

source program in assembly language
随机推荐
直播预告|30分钟快速入门!来看可信分布式AI链桨的架构设计
Opening - Open a new .NET modern application development experience
Tree search (bintree)
优化Feed流遭遇拦路虎,是谁帮百度打破了“内存墙”?
【OpenCV 图像处理2】:OpenCV 基础知识
2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
matlab绘制用颜色表示模值大小的箭头图
用@Mapper查询oracle的分区情况报错
the mechanism of ideology
std::string::find 返回值的坑
如何基于OpenVINO POT工具简单实现对模型的量化压缩
source program in assembly language
EBS uses virtual columns and hint hints to optimize sql case
没有对象的程序员如何过七夕
Transfer Learning - Distant Domain Transfer Learning
使用SuperMap iDesktopX数据迁移工具迁移地图文档和符号
CMS website construction process
C学生管理系统 据学号查找学生节点
Exploding the circle of friends, Alibaba produced billion-level concurrent design quick notes are too fragrant
C语言基础知识 -- 指针