当前位置:网站首页>C student management system Find student nodes based on student ID
C student management system Find student nodes based on student ID
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;
//Find student information at a given location.
STUNODE* FindStuByNum(char* arrStuNum);
int main()
{
int nOrder = -1;
char arrStuNum[10] = { '\0' };
char arrStuName[10] = { '\0' };
int iStuScore = -1;
int nFlag = 1;
//显示指令.
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("Enter the student number you want to find:");
scanf("%s", arrStuNum);
if (NULL != FindStuByNum(arrStuNum));
{
//插入.
}
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;
}
STUNODE* FindStuByNum(char* arrStuNum)
{
STUNODE* pTemp = g_pHead;
//检测参数的合法性.
if (NULL == arrStuNum)
{
printf("学号输入错误!\n");
return NULL;
}
//判断链表是否为空.
if (NULL == g_pHead || NULL == g_pEnd)
{
printf("链表为NULL!\n");
return NULL;
}
//遍历链表.
while (pTemp != NULL)
{
if (0 == strcmp(pTemp->arrStuNum, arrStuNum))
{
return pTemp;
}
pTemp = pTemp->pNext;
}
printf("查无此节点!\n");
return NULL;
}
边栏推荐
猜你喜欢
C语言实现简单猜数字游戏
Advanced Numbers_Review_Chapter 1: Functions, Limits, Continuity
直播预告|30分钟快速入门!来看可信分布式AI链桨的架构设计
2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
Flink 1.15.1 集群搭建(StandaloneSession)
常见的硬件延迟
树形查找(二叉查找树)
matlab绘制用颜色表示模值大小的箭头图
1349. Maximum number of students taking the exam Status Compression
Tree search (bintree)
随机推荐
Access Characteristics of Constructor under Inheritance Relationship
How to simply implement the quantization and compression of the model based on the OpenVINO POT tool
fragment可见性判断
ARM Mailbox
LPQ(局部相位量化)学习笔记
继承关系下构造方法的访问特点
ARM Mailbox
力扣-相同的树
Advanced Numbers_Review_Chapter 1: Functions, Limits, Continuity
Amazon Cloud Technology joins hands with Thundersoft to build an AIoT platform for industry customers
LeetCode uses the minimum cost to climb the stairs----dp problem
从零到一快速学会三子棋
【C语言】详解栈和队列(定义、销毁、数据的操作)
hypervisor相关的知识点
Transfer Learning - Joint Geometrical and Statistical Alignment for Visual Domain Adaptation
Log an error encountered when compiling google gn "I could not find a ".gn" file ..."
特殊矩阵的压缩存储
Leetcode刷题——22. 括号生成
Quickly learn chess from zero to one
浅谈数据安全治理与隐私计算