题目要求
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,若匹配&