当前位置:网站首页>C学生管理系统 指定位置插入学生节点
C学生管理系统 指定位置插入学生节点
2022-08-05 02:05: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;
//申明链表的头和尾。
STUNODE* g_pHead = NULL;
STUNODE* g_pEnd = NULL;
//指定位置添加学生信息。
void InSertNod(STUNODE* pTemp, 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;
STUNODE* pTemp = NULL;
//显示指令。
ShowOrder();
while (nFlag)
{
printf("请输入操作指令(0为查看指令)\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 11://指定位置添加。
printf("输入需要查找的学号:");
scanf("%s", arrStuNum);
pTemp = FindStuByNum(arrStuNum);
if (NULL != pTemp);
{
//插入。
printf("输入学号:");
scanf("%s", arrStuNum);
printf("输入姓名:");
scanf("%s", arrStuName);
printf("输入分数:");
scanf("%d", &iStuScore);
InSertNod(pTemp, 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;
}
//指定位置添加学生信息。
void InSertNod(STUNODE* pTemp, char* arrStuNum[10], char arrStuName[10], int iStuScore)
{
//创建节点。
STUNODE* pNewTemp = malloc(sizeof(STUNODE));
//成员赋值。
strcpy(pNewTemp->arrStuNum, arrStuNum);//因为数组做参数传入时则完全是一个指针。
strcpy(pNewTemp->arrStuName, arrStuName);//因为数组做参数传入时则完全是一个指针。
pNewTemp->iStuScore = iStuScore;
pNewTemp->pNext = NULL;
if (pTemp == g_pEnd)//是尾节点。
{
g_pEnd->pNext = pNewTemp;//尾结点下一个指向pNewTmep。
g_pEnd = pNewTemp;//尾结点变成pNewTmep。
}
else//中间节点。
{
pNewTemp->pNext = pTemp->pNext;
pTemp->pNext = pNewTemp;
}
}
边栏推荐
- dotnet 6 为什么网络请求不跟随系统网络代理变化而动态切换代理
- [parameters of PyQT5 binding functions]
- tcp中的三次握手与四次挥手
- KingbaseES V8 GIS data migration solution (2. Introduction to the capabilities of Kingbase GIS)
- Transfer Learning - Joint Geometrical and Statistical Alignment for Visual Domain Adaptation
- Why is this problem reported when installing oracle11
- Greenplum数据库故障分析——能对数据库base文件夹进行软连接嘛?
- ".NET IoT from scratch" series
- Hypervisor related knowledge points
- 方法重写与Object类
猜你喜欢

2022 EdgeX中国挑战赛8月3日即将盛大开幕
![[Redis] Redis installation under Linux](/img/84/7791a87ff976be15b455f6ddc05bf2.png)
[Redis] Redis installation under Linux

方法重写与Object类
![[Endnote] Word inserts a custom form of Endnote document format](/img/70/e8a6f15b80e9c53db369fd715e51df.png)
[Endnote] Word inserts a custom form of Endnote document format

汇编语言之源程序

在这个超连接的世界里,你的数据安全吗

Flink 1.15.1 集群搭建(StandaloneSession)

Transfer Learning - Joint Geometrical and Statistical Alignment for Visual Domain Adaptation

第09章 性能分析工具的使用【2.索引及调优篇】【MySQL高级】

如何发现一个有价值的 GameFi?
随机推荐
Greenplum Database Fault Analysis - Why Does gpstart -a Return Failure After Version Upgrade?
记录谷歌gn编译时碰到的一个错误“I could not find a “.gn“ file ...”
ExcelPatternTool: Excel table-database mutual import tool
迁移学习——Distant Domain Transfer Learning
亚马逊云科技携手中科创达为行业客户构建AIoT平台
Greenplum Database Fault Analysis - Can a Soft Connection Be Made to the Database Base Folder?
A new technical director, who calls DDD a senior, is convinced
Day Fourteen & Postman
树形查找(二叉查找树)
英特尔 XDC 2022 精彩回顾:共建开放生态,释放“基建”潜能
Transfer Learning - Joint Geometrical and Statistical Alignment for Visual Domain Adaptation
How to deal with your own shame
线性表的查找
How to create an rpm package
IJCAI2022 | DictBert:采用对比学习的字典描述知识增强的预训练语言模型
力扣-二叉树的最大的深度
<开发>实用工具
Live preview | 30 minutes started quickly!Look at credible distributed AI chain oar architectural design
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
CMS建站流程