小符的C语言课程设计——新生管理系统

本文介绍了使用C语言进行新生管理系统的设计,包括添加、修改、删除、保存和查询学生信息等功能。重点在于链表和指针的应用,以及通过排序和排名功能来展示数据。虽然初次实现时遇到了文件保存和读取的问题,但通过学长的指导,理解了如何构建一个完整的链表结构以解决该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>

定义一个student结构体,并将其定义别名为stu

typedef struct student
{
   
	char xuehao[200]; 
    char xingming[10];
    char xingbie[5];
    int nianling;
    char zhuanye[20];
    char dizhi[200];
    int shengri;
    int chengji;
	struct student *next;
}stu;


void chuangjian(stu*head); 
void xiugai(stu*head);
void baocun(stu*head);
void charu(stu*head);
void chaxun(stu*head);
void PaiMingBiao(stu *head);
void paixv(stu *head);
void xianshi(stu*head);
void xiugai(stu*head);
void duqu(stu *head);

创建新生信息(添加学生信息)

void chuangjian(stu *head)
{
   
	system ("cls");
//清屏函数
	stu *p;
	p=head;
//申请动态空间给p1
	stu *p1=(student*)malloc(sizeof(student));
	//向p1中存入数据
		printf("请输入学号:\n");
		scanf("%s",&p1->xuehao);
		printf("请输入姓名;\n");
		scanf("%s",&p1->xingming);
		printf("年龄:\n");
		scanf("%d",&p1->nianling);
		printf("请输入性别:\n");
		scanf("%s",&p1->xingbie);
		printf("请输入专业:\n");
		scanf("%s",&p1->zhuanye);
		printf("请输入入学英语成绩:\n");
		scanf("%d",&p1->chengji);
		printf("请输入家庭地址:\n");
		scanf("%s",&p1->dizhi);
		printf("请输入生日:\n");
		scanf("%d",&p1->shengri);
		while(p->next!=NULL)
//若为首条存入信息,此时p->next=NULL,故不进入第二个while循
//环,连接head与p1,p1->next=NULL,显示“添加成功!”
		{
   
			while(strcmp(p->next->xuehao,p1->xuehao)==0)
			{
   
//添加信息时比较学号是否相同,此时p->next!=NULL,进入第二个
//while循环,若p->next内容与p1内容一致,则会输出“已存在”,
//在期间内,p不断向后移动,直到p-next==NULL时,与p1连接(p1的
//插入使用的是尾插法)
			printf("该学生已存在!\n");
			return;	
			}
			p=p->next;
		}
        p->next=p1;
        p1->next=NULL;
		printf("添加成功!\n"); 
}

修改学生信息

//首先需明白,在进行此环节时,程序中已经存在一段链表
void xiugai(stu*head)
{
   
	system ("cls");
//定义指针p指向头结点的下一个节点
	stu*p=head->next;
	char xuehao[200];
	printf("请输入你想修改的学生的学号\n");
	scanf("%s",xuehao);
	while(p!=NULL)
//p一直向后移动直到节点中的学号与输入的一致,停止,修改
	{
   
		if(strcmp(xuehao,p->xuehao)==0)
		{
   
			
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值