当前位置:网站首页>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;
}
}
边栏推荐
- 意识形态的机制
- [ROS](10)ROS通信 —— 服务(Service)通信
- [Unity Entry Plan] Handling of Occlusion Problems in 2D Games & Pseudo Perspective
- Live playback including PPT download | Build Online Deep Learning based on Flink & DeepRec
- 力扣-二叉树的最大的深度
- [Word] #() error occurs after Word formula is exported to PDF
- 编译预处理等细节
- 亚马逊云科技携手中科创达为行业客户构建AIoT平台
- Matlab map with color representation module value size arrow
- mysql树状结构查询问题
猜你喜欢
继承关系下构造方法的访问特点
如何基于OpenVINO POT工具简单实现对模型的量化压缩
[Unity Entry Plan] Handling of Occlusion Problems in 2D Games & Pseudo Perspective
【MySQL series】- Does LIKE query start with % will make the index invalid?
【LeetCode刷题】-数之和专题(待补充更多题目)
迁移学习——Distant Domain Transfer Learning
How to simply implement the quantization and compression of the model based on the OpenVINO POT tool
matlab绘制用颜色表示模值大小的箭头图
Utilities [Endnote] Word inserts a custom form of Endnote document format
随机推荐
短域名绕过及xss相关知识
select 标签自定义样式
协作D2D局部模型聚合的半分散联合学习
SuperMap支持的国产环境汇总
编译预处理等细节
matlab绘制用颜色表示模值大小的箭头图
Programmer's list of sheep counting when insomnia | Daily anecdote
网络安全与元宇宙:找出薄弱环节
PHP Skills Assessment
领域驱动设计——MDD
【LeetCode刷题】-数之和专题(待补充更多题目)
Optimizing the feed flow encountered obstacles, who helped Baidu break the "memory wall"?
优化Feed流遭遇拦路虎,是谁帮百度打破了“内存墙”?
基于OpenVINO工具套件简单实现YOLOv7预训练模型的部署
Leetcode刷题——22. 括号生成
std::string::find 返回值的坑
继承关系下构造方法的访问特点
RAID磁盘阵列
散列表的查找(哈希表)
The 2022 EdgeX China Challenge will be grandly opened on August 3