当前位置:网站首页>C student management system Insert the student node at the specified location
C student management system Insert the student node at the specified location
2022-08-05 02:19: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;//End node next pointpNewTmep.
g_pEnd = pNewTemp;//End node intopNewTmep.
}
else//中间节点.
{
pNewTemp->pNext = pTemp->pNext;
pTemp->pNext = pNewTemp;
}
}
边栏推荐
- 2022 EdgeX中国挑战赛8月3日即将盛大开幕
- 2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
- oracle将restful接口封装到视图中
- [LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)
- 在这个超连接的世界里,你的数据安全吗
- Exploding the circle of friends, Alibaba produced billion-level concurrent design quick notes are too fragrant
- 协作D2D局部模型聚合的半分散联合学习
- Transfer Learning - Joint Geometrical and Statistical Alignment for Visual Domain Adaptation
- 亚马逊云科技 + 英特尔 + 中科创达为行业客户构建 AIoT 平台
- 高数_复习_第1章:函数、极限、连续
猜你喜欢
SuperMap iDesktop.Net之布尔运算求交——修复含拓扑错误复杂模型
How do programmers without objects spend the Chinese Valentine's Day
[Unity Entry Plan] Handling of Occlusion Problems in 2D Games & Pseudo Perspective
[ROS](10)ROS通信 —— 服务(Service)通信
KingbaseES V8 GIS data migration solution (2. Introduction to the capabilities of Kingbase GIS)
Matlab map with color representation module value size arrow
leetcode 15
Quickly learn chess from zero to one
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中
使用SuperMap iDesktopX数据迁移工具迁移ArcGIS数据
随机推荐
C语言实现简单猜数字游戏
std::string::find 返回值的坑
PHP技能评测
Greenplum数据库故障分析——版本升级后gpstart -a为何返回失败
基于OpenVINO工具套件简单实现YOLOv7预训练模型的部署
行业案例|世界 500 强险企如何建设指标驱动的经营分析系统
How to simply implement the quantization and compression of the model based on the OpenVINO POT tool
Greenplum Database Fault Analysis - Can a Soft Connection Be Made to the Database Base Folder?
C学生管理系统 据学号查找学生节点
优化Feed流遭遇拦路虎,是谁帮百度打破了“内存墙”?
Residential water problems
【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗
Xunrui cms website cannot be displayed normally after relocation and server change
Opening - Open a new .NET modern application development experience
用@Mapper查询oracle的分区情况报错
"Configuration" is a double-edged sword, it will take you to understand various configuration methods
蚁剑高级模块开发
mysql树状结构查询问题
继承关系下构造方法的访问特点
程序员失眠时的数羊列表 | 每日趣闻