当前位置:网站首页>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;
}
}
边栏推荐
- MySQL learning
- 释放技术创新引擎,英特尔携手生态合作伙伴推动智慧零售蓬勃发展
- Xunrui cms website cannot be displayed normally after relocation and server change
- Live playback including PPT download | Build Online Deep Learning based on Flink & DeepRec
- 蚁剑高级模块开发
- Amazon Cloud Technology joins hands with Thundersoft to build an AIoT platform for industry customers
- 1349. Maximum number of students taking the exam Status Compression
- 亚马逊云科技携手中科创达为行业客户构建AIoT平台
- 行业案例|世界 500 强险企如何建设指标驱动的经营分析系统
- mysql树状结构查询问题
猜你喜欢
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
LeetCode使用最小花费爬楼梯----dp问题
【LeetCode刷题】-数之和专题(待补充更多题目)
优化Feed流遭遇拦路虎,是谁帮百度打破了“内存墙”?
刷爆朋友圈,Alibaba出品亿级并发设计速成笔记太香了
“嘀哩哩,等灯等灯”,工厂安全生产的提示音
【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗
HOG feature study notes
How to simply implement the quantization and compression of the model based on the OpenVINO POT tool
在这个超连接的世界里,你的数据安全吗
随机推荐
CPDA|运营人如何从负基础学会数据分析(SQL)
Leetcode刷题——22. 括号生成
继承关系下构造方法的访问特点
02 【开发服务器 资源模块】
MySQL3
Flink 1.15.1 集群搭建(StandaloneSession)
EBS uses virtual columns and hint hints to optimize sql case
Unleashing the engine of technological innovation, Intel joins hands with ecological partners to promote the vigorous development of smart retail
The 2022 EdgeX China Challenge will be grandly opened on August 3
RAID磁盘阵列
PHP Skills Assessment
"Dilili, wait for the lights, wait for the lights", the prompt sound for safe production in the factory
HOG feature study notes
Matlab map with color representation module value size arrow
1349. Maximum number of students taking the exam Status Compression
使用SuperMap iDesktopX数据迁移工具迁移地图文档和符号
一文看懂推荐系统:召回06:双塔模型——模型结构、训练方法,召回模型是后期融合特征,排序模型是前期融合特征
散列表的查找(哈希表)
【genius_platform软件平台开发】第七十六讲:vs预处理器定义的牛逼写法!!!!(其他组牛逼conding人员告知这么配置来取消宏定义)
[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)