当前位置:网站首页>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;
}
}
边栏推荐
- C language basics -- pointers
- 线性表的查找
- Flink 1.15.1 集群搭建(StandaloneSession)
- 力扣-二叉树的最大的深度
- Fragment visibility judgment
- the mechanism of ideology
- ExcelPatternTool: Excel表格-数据库互导工具
- 短域名绕过及xss相关知识
- Residential water problems
- Exploding the circle of friends, Alibaba produced billion-level concurrent design quick notes are too fragrant
猜你喜欢

MySQL3

Xunrui cms website cannot be displayed normally after relocation and server change

《.NET物联网从零开始》系列

CPDA|运营人如何从负基础学会数据分析(SQL)

iNFTnews | 对体育行业和球迷来说,NFT可以带来什么?

【Unity入门计划】2D游戏中遮挡问题的处理方法&伪透视
![[Redis] Redis installation under Linux](/img/84/7791a87ff976be15b455f6ddc05bf2.png)
[Redis] Redis installation under Linux
![[How to smash wool according to the music the couple listens to during the Qixi Festival] Does the background music affect the couple's choice of wine?](/img/eb/535ffaff9b535fbc73a4d56aab0b3a.png)
[How to smash wool according to the music the couple listens to during the Qixi Festival] Does the background music affect the couple's choice of wine?

英特尔 XDC 2022 精彩回顾:共建开放生态,释放“基建”潜能

方法重写与Object类
随机推荐
浅谈数据安全治理与隐私计算
Greenplum数据库故障分析——能对数据库base文件夹进行软连接嘛?
Greenplum数据库故障分析——版本升级后gpstart -a为何返回失败
[How to smash wool according to the music the couple listens to during the Qixi Festival] Does the background music affect the couple's choice of wine?
开篇-开启全新的.NET现代应用开发体验
MySQL learning
How do programmers without objects spend the Chinese Valentine's Day
ExcelPatternTool: Excel table-database mutual import tool
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
.Net C# 控制台 使用 Win32 API 创建一个窗口
学习笔记-----左偏树
刷爆朋友圈,Alibaba出品亿级并发设计速成笔记太香了
day14--postman接口测试
转:查尔斯·汉迪:你是谁,比你做什么更重要
力扣-相同的树
SAP ERP和ORACLE ERP的区别是哪些?
MySQL3
the mechanism of ideology
Exploding the circle of friends, Alibaba produced billion-level concurrent design quick notes are too fragrant
【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗