双向循环链表编写简单学生信息管理系统(C语言)

题目要求
1:要求有登陆功能
2:成员信息:学号,语数外成绩,账号,密码,性别,身份(老师还是学生),以及地址
3:老师和学生都可以修改自己的密码
4:老师可以增加或者删除学生
5:学生只可以查看自己的成绩
6:老师可以查看所有学生的成绩,以及修改本科的成绩

#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
typedef struct node
{
	int id_num;//teacher or student's number
	char status;//teacher : t , student : s
	int chinese;
	int math;
	int English;
	int passwd;
	char address[64];
	char sex;//man : m , women : w
	struct node *next;
}*listnode;

listnode listnode_init()
{
	listnode head = malloc(sizeof(struct node)); //申请头结点空间
	if(head == NULL)
	{
		perror("list init error");
		return NULL;
	}
	head->next = NULL;
	return head;//返回头结点地址
}

void data_init(listnode newnode ,int id_num,char status,int chinese,int math ,int English , int passwd,char * address,char sex)
{
	newnode->id_num = id_num;
	newnode->status = status;
	newnode->chinese = chinese;
	newnode->math = math;
	newnode->English = English;
	newnode->passwd = passwd;
	strcpy(newnode->address,address);
	newnode->sex = sex;
}

bool add_node(listnode head,int id_num,char status,int chinese,int math ,int English , int passwd,char * address,char sex)
{
	listnode newnode = malloc(sizeof(struct node));
	if(newnode == NULL)
	{
		perror("malloc newnode error");
		return -1;
	}
	//2、初始化节点数据
    data_init(newnode ,id_num,status,chinese,math ,English,passwd,address,sex);
    	
	//3找到链表尾部
	listnode p = head;
	while(p->next != NULL)  //如果p->next不等于 NULL,证明后面还有节点
	{
		p = p->next;	
	}
	newnode->next = p->next;
	p->next = newnode;	
	printf("尾插法所接入的数据 %d,%c\n", p->next->id_num,p->next->status);
    return 0;
}

listnode search_member_prev(listnode head ,int id_number)
{
	listnode tmp = head ;
	while(tmp->next != NULL)
	{
		if(tmp->next->id_num == id_number)
		{
			return tmp ;
		}	
        tmp = tmp->next;		
	}
	return NULL;
}

//传入头节点,和另一个节点
//函数中输入 id_num 和 passwd,若匹配&
  • 2
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值