当前位置:网站首页>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;
}
}
边栏推荐
- oracle将restful接口封装到视图中
- 【genius_platform软件平台开发】第七十六讲:vs预处理器定义的牛逼写法!!!!(其他组牛逼conding人员告知这么配置来取消宏定义)
- 优化Feed流遭遇拦路虎,是谁帮百度打破了“内存墙”?
- HOG特征学习笔记
- Domain Driven Design - MDD
- “配置”是把双刃剑,带你了解各种配置方法
- J9数字货币论:web3的创作者经济是什么?
- [Unity Entry Plan] Handling of Occlusion Problems in 2D Games & Pseudo Perspective
- mysql树状结构查询问题
- The difference between a process in user mode and kernel mode [exclusive analysis]
猜你喜欢
海量服务实例动态化管理
DAY23:命令执行&代码执行漏洞
Chapter 09 Use of Performance Analysis Tools [2. Index and Tuning] [MySQL Advanced]
RAID磁盘阵列
How do programmers without objects spend the Chinese Valentine's Day
js中try...catch和finally的用法
Tree search (bintree)
C language diary 9 3 kinds of statements of if
浅谈数据安全治理与隐私计算
DAY23: Command Execution & Code Execution Vulnerability
随机推荐
Greenplum Database Fault Analysis - Why Does gpstart -a Return Failure After Version Upgrade?
Domain Driven Design - MDD
汇编语言之源程序
编译预处理等细节
【PyQT5 绑定函数的传参】
Greenplum数据库故障分析——版本升级后gpstart -a为何返回失败
英特尔 XDC 2022 精彩回顾:共建开放生态,释放“基建”潜能
蚁剑高级模块开发
02 【开发服务器 资源模块】
EBS uses virtual columns and hint hints to optimize sql case
select 标签自定义样式
【日常训练】1403. 非递增顺序的最小子序列
MySQL3
How to simply implement the quantization and compression of the model based on the OpenVINO POT tool
Using OpenVINO to implement the flying paddle version of the PGNet inference program
海量服务实例动态化管理
记录谷歌gn编译时碰到的一个错误“I could not find a “.gn“ file ...”
[parameters of PyQT5 binding functions]
SDC简介
继承关系下构造方法的访问特点