精华内容
下载资源
问答
  • 老师布置的课设作业,要求用双向链表实现学生信息管理系统,学生信息包括学号,姓名,年龄,入学日期,电话等,实现增删改操作。。大神教教我吧,c++和java都可以,拜托![图片说明]...
  • 改源代码用链表实现了学生信息的增删改查,读写入(出)文件,同时实现了学生信息的排序,链表的清空,插入。双向链表的插入排序,能够帮助学习链表。
  • 利用C语言双向链表实现的学生信息管理系统Demo
  • 题目要求 ...4:老师可以增加或者删除学生 5:学生只可以查看自己的成绩 6:老师可以查看所有学生的成绩,以及修改本科的成绩 #include<stdio.h> #include<stdlib.h> #include<stdbool.h...

    题目要求
    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,若匹配,返回true
    listnode login_in(listnode head,listnode newOne)
    {
    	int passwdInput,id_num;
    	listnode new = head;
    	printf("please input your id_num(five Number): ");
    	if(scanf("%d",&(id_num)) == 1)
    	{
    		while(getchar() != '\n');
    		listnode tmp = search_member_prev(head,id_num);
    	    if(tmp != NULL)
    		{
    			printf("please input your password :");
    			scanf("%d",&passwdInput);
    			while(getchar() != '\n');
    			if(tmp->next->passwd == passwdInput)
    			{
    				newOne = tmp;
    				return newOne;
    			}
    		}
    	}
    	return NULL;
    }
    
    int JudgeStuTea(listnode head ,listnode newOne)
    {
    	printf("1");
    	int number = newOne->next->id_num ;
    	listnode tmp = search_member_prev(head,number);
    	if( tmp->next->status == 't')
    	{
    		printf("this is a teacher\n");
    		return 1;
    	}
    	else
    		return 0;
    }
    
    void show_grade(listnode newOne)
    {
    	printf("                                     %d \n",         newOne->next->id_num);
    	printf("                                     chinese : %d\n",newOne->next->chinese);
    	printf("                                     math    : %d\n",newOne->next->math);
    	printf("                                     English : %d\n\n",newOne->next->English);
    }
    //修改密码
    bool alter_passwd(listnode newOne)
    {
    	char Judge;
    	int passwd;
    	printf("your password : %d\n",newOne->next->passwd);
    	printf("You are sure about changing Your pasword ? y/n : \n");
        scanf("%c",&Judge);
    	while(getchar()!='\n');
    	if(Judge == 'y')
    	{
    		printf("please input your new password :\n");
    		scanf("%d",&passwd);
    		newOne->next->passwd = passwd;
    		printf("%d\n",newOne->next->passwd);
    	    return true;
    	}
    	else
    	{
    		printf("don't waste my time , bitch !\n");
    		return false;
    	}
    }
    
    //学生操作
    void StuMove(listnode head , listnode newOne)
    {
    	int numberOption;
    	while(1)
    	{
    		printf(" hello ,%d \n",newOne->next->id_num);
    		printf(" press 0 : show your all grade \n\n");
    		printf(" press 1 : alter your passwd \n\n\n");
    		printf(" press 2 : exit\n\n");
    		printf(" Your option : \n");
    		scanf("%d",&numberOption);
    		while(getchar() != '\n');
    		switch(numberOption)
    		{
    			case 0:
    			    show_grade(newOne);
    				break;
    			case 1:
    			    alter_passwd(newOne);
    				break;
    			case 2:
    			    return;
    		}
    	}
    }
    
    //打印所有的成员信息
    void show_all(listnode head)
    {
    	listnode tmp = head;
    	while(tmp->next != NULL)
    	{
    		printf("\tI\tS\tC\tM\tE\tA\t\tSEX\n\n");
    		printf("\t%d\t%c\t%d\t%d\t%d\t%s\t%c\t\n\n",tmp->next->id_num,tmp->next->status,tmp->next->chinese,tmp->next->math ,tmp->next->English ,tmp->next->address,tmp->next->sex);
    	    tmp = tmp->next;
    	}
    }
    
    listnode add_grades(listnode head)
    {
    	listnode tmp = head;
    	char addressInput[20];
    	
    	while(tmp->next != NULL)
    	{
    		tmp = tmp->next;
    	}
    	listnode new  = malloc(sizeof(struct node));
    	printf("\n\n");
    	printf("please input the student 's id : ");
    	scanf("%d",&(new->id_num));
    	while(getchar() != '\n');
    	printf("\n\n");
    	new->status = 's';
    	printf("please input the student 's chinese : ");
    	scanf("%d",&(new->id_num));
    	while(getchar() != '\n');
    	printf("\n\n");
    	printf("please input the student 's math : ");
    	scanf("%d",&(new->math));
    	while(getchar() != '\n');
    	printf("\n\n");
    	printf("please input the student 's English : ");
    	scanf("%d",&(new->English));
    	while(getchar() != '\n');
    	printf("\n\n");
    	printf("please input the student 's passwd : ");
    	scanf("%d",&(new->passwd));
    	while(getchar() != '\n');
    	printf("\n\n");
    	printf("please input the student 's address : ");
    	gets(addressInput);
    	strcpy(new->address,addressInput);
    	printf("\n\n");
    	printf("please input the student 's sex : ");
    	scanf("%c",&(new->sex));
    	while(getchar() != '\n');
    	tmp->next = new;
    	show_all(head);
    	return head;
    }
    
    //修改学生信息
    bool alter_grades(listnode head,listnode newOne)
    {
    	int id_num,grade,subject,judgeStu,teaSubject = 0;
    	printf("please input the student's id_num :");
        scanf("%d",&id_num);
    	while(getchar() != '\n');
    	listnode tmp = search_member_prev(head ,id_num);
    	//根据id_num在学生列表中匹配学生,若匹配成功,且该id_num不是一个老师 tmp->next->status != 't'
    	//则进行下一步操作
    	if( ( tmp != NULL ) && (tmp->next->status != 't'))
    	{
    		printf("is he this guy ?(y:1,n:0)\n");
    		show_grade(tmp);
    		scanf("%d",&judgeStu);
    		while(getchar()!='\n');
    		if(judgeStu == 1)
    		{
    			//这里匹配登陆账号老师是教哪一科的,从而修改具体学生哪一科的成绩
    			if(newOne->next->math == -1)
    			{
    				printf(" how much about math : ");
    				scanf("%d",&(tmp->next->math));
    				show_grade(tmp);
    				return true;
    			}
    			else
    			    if(newOne->next->chinese == -1)
    			{
    				printf(" how much about chinese : ");
    				scanf("%d",&(tmp->next->chinese));
    				show_grade(tmp);
    				return true;
    			}
    			else 
    				if(newOne->next->English == -1)
    			{
    				printf(" how much about English : ");
    				scanf("%d",&(tmp->next->English));
    			    show_grade(tmp);
    				return true;
    			}
    				
    		}
    	}
    	return false;
    	
    }
    
    //学生删除操作 参数:一个listnode 的头节点
    void student_delete(listnode head)
    {
    	int id_number,judgeStu;
    	listnode tmp = head;
    	listnode disap;
    	printf("who , delete :");
    	scanf("%d",&id_number);
    	//根据输入寻找学生,
    	tmp = search_member_prev(head ,id_number);
    	if(tmp != NULL)
    	{
    		printf("is he this guy ?(y:1,n:0)\n");
    		show_grade(tmp);
    		scanf("%d",&judgeStu);
    		if(judgeStu == 1)
    		{
    			disap = tmp->next;
    			tmp->next = tmp->next->next;
    			free(disap);	
    			show_all(head);
    			printf("delete student successfully");
    		}
    		else
    		{
    			printf("delete failed");
    		}
    	}
    }
    
    
    //老师操作选项
    //根据输入选择老师可以进行的功能
    void TeaMove(listnode head,listnode newOne)
    {
    	int options;
    	while(1)
    	{
    		printf(" welcome , %d",newOne->next->id_num);
    		printf(" press 0 : change your passwd\n");
    		printf(" press 1 : show the all grades\n");
    		printf(" press 2 : alter one student's grades\n");
    		printf(" press 3 : delete one student\n");
    		printf(" press 4 : add one student\n");
    		printf(" press 5 : exit\n\n");
    		scanf("%d",&options);
    		while(getchar()!= '\n');
    			switch(options)
    			{
    				case 0:
    					alter_passwd(newOne);
    					break;
    				case 1:
    					show_all(head);
    					break;
    				case 2:
    					alter_grades(head,newOne);
    					break;
    				case 3:
    					student_delete(head);
    					break;
    				case 4:
    				    head = add_grades(head);
    					break;
    				case 5:
    					return;
    			}
    		}
    }
    
    
    int main()
    {
    	//先插入几个学生和老师的信息
    	listnode head = listnode_init();
    	add_node(head,20161,'t',-1,0,0,123456,"hubeijinghzou",'w');
    	add_node(head,20162,'t',0,-1,0,123457,"hubeiwuhan",'m');
    	add_node(head,20163,'t',0,0,-1,123458,"hubeixiaogan",'m');
    	add_node(head,20164,'s',59,60,61,123459,"hubeijingzhou",'w');
    	add_node(head,20165,'s',79,73,77,123450,"hubeijingzhou",'m');
    	add_node(head,20166,'s',99,83,87,223450,"hubeijingzhou",'m');
    	//验证登陆信息
    	listnode newOne = head->next;
    	while(1)
    	{
    		newOne = login_in(head,newOne);
    		if(newOne != NULL)
    			break;
    	}
    	//欢迎界面
    	printf("welcome to zhangke's school info manage system :\n\n");
    	//进行判断,如果是老师,进入 TeaMove
    	//如果是学生,进入StuMove
    	if( JudgeStuTea(head,newOne) == 1 )
    		TeaMove(head,newOne);
    	else
    		StuMove(head,newOne);
    	
    }
    
    

    思路:
    1 登陆:我们需要实现登陆功能,我的做法是程序运行时,我先初始化链表,然后插入几个成员信息,包括学生和老师的,(这在主函数的 add_node中可以看到插入了6个成员),你也可以改变思路:初始化链表之后,先进行 add_grades() (即添加成员,再进行登陆程序),
    2 老师:在老师的设定上,我采取了这样的方法,老师没有语数外成绩,教哪一科就将哪一科的成绩设定为-1,登陆监测到是老师就进行Tea_move,然后一个死循环,中间加switch(),对输入的功能选项进行选择,这里,老师查看成绩时,调用的是show_all
    3 学生没什么好说的,只有查看成绩时,调用show_grades
    4,链表这一块,掌握最基本的增删改查就可以了,然后进行一些练习,在调试程序的时候多加一些priintf();才能更好的查看错误以及程序的运行情况,否则,程序运行报错只有一个段错误,真的惨

    展开全文
  • printf("学生成绩管理系统:\n"); printf(" 输入学生成绩-----------------0\n"); printf(" 下载纪录-----------------1\n"); printf(" 显示所有成绩-------------2\n"); printf(" 存盘-----------...
  • StudentManage.h: #include #include #include //#include #define N 100 //#define CHIN typedef struct student { int studentID; char name[N]; int age; int sex; }STUDENT;...typedef s

    StudentManage.h:

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    //#include <curses.h>
    
    #define N 100
    //#define CHIN 
    
    typedef struct student
    {
        int studentID;
        char name[N];
        int age;
        int sex;
    }STUDENT;
    
    typedef struct score
    {
        int chinese;
        int math;
        int english;
        int average;
        int total;
    }SCORE;
    
    typedef struct node
    {
        STUDENT stu;
        SCORE sc;
        struct node *next;
        struct node *pione;
    }NODE;
    
    extern NODE * mycreate();
    extern NODE * myinsert(NODE *,STUDENT *,SCORE *);
    extern void mycopy(NODE *,STUDENT *,SCORE *);
    extern void myprint(NODE *);
    extern NODE * myremove(NODE **,int);
    extern int Doublelinklistlen(NODE *);
    //extern NODE * mysearch(NODE *);
    //extern NODE * mysort(NODE *);
    extern void display(NODE *);
    extern void addstudent(NODE *);
    extern void lookover(NODE *);
    extern void deletestudent(NODE *);
    extern NODE * mysearch(NODE *,int);
    extern void searchinfo(NODE *);
    //extern NODE *mysort(NODE *);
    //extern void sortinfo(NODE *);
    extern void printnode(NODE *);
    


    StudentManage.c:

    #include "StudentManage.h"
    
    void mycopy(NODE *node,STUDENT *student,SCORE *score)
    {
        node->stu.studentID = student->studentID;
        strcpy(node->stu.name,student->name);
        node->stu.age = student->age;
        node->stu.sex = student->sex;
        node->sc.chinese = score->chinese;
        node->sc.math = score->math;
        node->sc.english = score->english;
        node->sc.average = score->average;
        node->sc.total = score->total;
    }
    
    NODE * mycreate()
    {
        NODE *head = (NODE *)malloc(sizeof(NODE));
        head->stu.studentID = 0;
        head->next = head;
        head->pione = head;
        return head;
    }
    
    NODE * myinsert(NODE *head,STUDENT *student,SCORE *score)
    {
        if(head->stu.studentID == 0)
        {
            mycopy(head,student,score);
        }
        else
        {
            NODE *last = head;
            while(last->next != head)
            {
                last = last->next;
            }
            NODE *p = (NODE *)malloc(sizeof(NODE));
    	memset(p,0,sizeof(p));
            mycopy(p,student,score);
            head->pione = p;
            last->next = p;
            p->next = head;
            p->pione = last;
        }
        return head;
    }
    
    void myprint(NODE *head)
    {
        NODE *q = (NODE *)malloc(sizeof(NODE));
        q = head;
        int i = 1;
        while(q->next != head)
        //while(i < Doublelinklistlen(head))
        {
            printf("No.%d:ID:%d\tName:%s\tAge:%d\tSex:%d\n",i,q->stu.studentID,q->stu.name,q->stu.age,q->stu.sex);
    	printf("   Chinese:%d\tMath:%d\tEnglish:%d\tAverage:%d\tTotal:%d\n",q->sc.chinese,q->sc.math,q->sc.english,q->sc.average,q->sc.total);
    	i++;
    	q = q->next;
    	printf("\n");
        }
        printf("No.%d:ID:%d\tName:%s\tAge:%d\tSex:%d\n",i,q->stu.studentID,q->stu.name,q->stu.age,q->stu.sex);
        printf("   Chinese:%d\tMath:%d\tEnglish:%d\tAverage:%d\tTotal:%d\n",q->sc.chinese,q->sc.math,q->sc.english,q->sc.average,q->sc.total);
    }
    
    void printnode(NODE *node)
    {
        if(node != NULL)
        {
            printf("ID:%d\tName:%s\tAge:%d\tSex:%d\n",node->stu.studentID,node->stu.name,node->stu.age,node->stu.sex);
            printf("Chinese:%d\tMath:%d\tEnglish:%d\tAverage:%d\tTotal:%d\n",node->sc.chinese,node->sc.math,node->sc.english,node->sc.average,node->sc.total);
        }
        else
        {
            printf(" ");
        }
        printf("\n");
    }
    
    int Doublelinklistlen(NODE *head)
    {
        int len = 0;
        NODE *q = head;
        while(q->next != head)
        {
            len++;
    	q = q->next;
        }
        return (len + 1);
    }
    
    NODE * myremove(NODE **head,int studentID)
    {
        //#define __DDD__
        NODE *q = (NODE *)malloc(sizeof(NODE));
        q = *head;
        int j = 0;
        while(q->stu.studentID != studentID)
        {
            j++;
            q = q->next;
    	if(j >= Doublelinklistlen(*head))
    	{
    	    #ifdef __DDD__
    	    printf("No Such Student has The studentID!\n");
    	    printf("Delete Student Failure!\n");
    	    #endif
    	    return *head;
    	}
        }
            NODE *pre = q->pione;
            NODE *ne = q->next;
            //pre->next = ne;
            //ne->pione = pre;
    	if(q == *head)
    	{
    	    (*head) = (*head)->next;
    	    pre->next = (*head);
    	    (*head)->pione = pre;
    	    free(q);
    	    q = NULL;
    	}
    	else
    	{
    	    pre->next = ne;
    	    ne->pione = pre;
    	    free(q);
    	    q = NULL; 
    	}
    	#ifdef __DDD__
    	printf("Delete Student Success!\n");
    	#endif
    	return (*head);
    }
    
    NODE * mysearch(NODE *head,int info)
    {
        NODE *q = head;
        int j = 0;
        #if 0
        int count = 0;
        for(i = 0; i < Doublelinklistlen(head); i++)
        {
            if((num == 1) && (q->stu.studentID == (int)info))
    	{
    	    printnode(q);
    	    count++;
    	    continue;
    	}
    	else if((num == 2) && (strcpy(q->stu.name,(char *)info) == 0))
    	{
    	    printnode(q);
    	    count++;
    	    continue;
    	}
    	else if((num == 3) && (q->stu.age == (int)info))
    	{
    	    printnode(q);
    	    count++;
    	    continue;
    	}
    	else if((num == 4) && (q->stu.sex == (int)info))
    	{
    	    printnode(q);
    	    count++;
    	    continue;
    	}
    	else
    	{
    	    ;
    	}
    	q = q->next;
        }
        if(count == 0)
        {
            printf("No infomation about you input!\n");
        }
        #endif
        #if 1
        while(q->stu.studentID != info)
        {
            j++;
            q = q->next;
    	if(j > Doublelinklistlen(head))
    	{
    	    printf("No This Student!\n");
    	    return NULL;
    	}
        }
        //printnode(q);
        return q;
        #endif
    }
    #if 0
    NODE * mysort(NODE *head)
    {
        NODE *newhead = mycreate();
        NODE *newlast = newhead;
        NODE *q = head;
        NODE *max = head;
        while(q != NULL)
        {
            printf("%d\n",__LINE__);
            for(; q->next != head; q = q->next)
    	{
            printf("%d\n",__LINE__);
    	//sleep(2);
    	    if(q->next->sc.total > max->sc.total)
    	    {
            printf("%d\n",__LINE__);
    	        max = q->next;
    	    }
    	}
            printf("%d\n",__LINE__);
    	if(max == head)
    	{
            printf("%d\n",__LINE__);
    	    NODE * ne = head->next;
    	    NODE * pre = head->pione;
    	    head = head->next;
    	    ne->pione = pre;
    	    pre->next = ne;
            printf("%d\n",__LINE__);
    	}
    	else
    	{
            printf("%d\n",__LINE__);
    	    NODE *ne = q->next;
    	    NODE *pre = q->pione;
    	    ne->pione = pre;
    	    pre->next = ne;
            printf("%d\n",__LINE__);
    	}
    	if(newhead->stu.studentID == 0)
    	{
            printf("%d\n",__LINE__);
    	    newhead = max;
    	    newlast = max;
            printf("%d\n",__LINE__);
    	}
    	else
    	{
    	    newlast->next = max;
    	    max->pione = newlast;
    	    max->next = newhead;
    	    newhead->pione = max;
    	    newlast = max; 
    	}
    	q = q->next;
        }
        return newhead;
    }
    #endif
    

    Display.c:

    #include "StudentManage.h"
    
    void addstudent(NODE *head)
    {
        STUDENT stu;
        SCORE sc;
        printf("Please Input Student's StudentID(12XXX):");
        scanf("%d",&stu.studentID);
        printf("Please Input Student's Name:");
        scanf("%s",stu.name);
        printf("Please Input Student's Age:");
        scanf("%d",&stu.age);
        printf("Please Input Student's Sex(1:男 0:女):");
        scanf("%d",&stu.sex);
        printf("Please Input Student's Chinese Score:");
        scanf("%d",&sc.chinese);
        printf("Please Input Student's Math Score:");
        scanf("%d",&sc.math);
        printf("Please Input Student's English Score:");
        scanf("%d",&sc.english);
        sc.average = (sc.chinese + sc.math + sc.english) / 3;
        sc.total = sc.chinese + sc.math + sc.english;
        system("clear");
        printf("The Infomation New Student:\n");
        printf("ID:%d\tName:%s\tAge:%d\tSex:%d\n",stu.studentID,stu.name,stu.age,stu.sex);
        printf("Chinese:%6d\tMath:%6d\tEnglish:%6d\n",sc.chinese,sc.math,sc.english);
        printf("Are You Sure To Add %d:%s ??(Y / N)",stu.studentID,stu.name);
        char ch;
        scanf("\n%c",&ch);
        if(ch == 'Y')
        {
            head = myinsert(head,&stu,&sc);
    	printf("Add Student Success!\n");
        }
        printf("Press Enter To Continue...\n");
        getchar();
        getchar();
    }
    
    void lookover(NODE *head)
    {
        printf("The Infomation Of Student :\n");
        myprint(head);
        printf("Press Enter To Continue...");
        getchar();
        getchar();
    }
    
    void deletestudent(NODE *head)
    {
        int id;
        #define __DDD__
        printf("Please Input The StudentID Of Student You Want To Delete(12XXX):");
        scanf("%d",&id);
        NODE *p = mysearch(head,id);
        printf("The Infomation New Student:\n");
        printnode(p);
        printf("Are You Sure To Add %d:%s ??(Y / N)",p->stu.studentID,p->stu.name);
        char ch;
        scanf("\n%c",&ch);
        if(ch == 'Y')
        {
            //head = myinsert(head,&stu,&sc);
    	//printf("Add Student Success!\n");
        
        //char ch;
            head = myremove(&head,id);
        }
        printf("Press Enter To Continue...");
        getchar();
        getchar();
    }
    
    void searchinfo(NODE *head)
    {
        
        int n;
        //#define __DDD__
        printf("Please Input StudentID You Want To Search(12XXX):");
        scanf("%d",&n);
        NODE *p = mysearch(head,n);
        printnode(p);
        #if 0
        int n;
        int info;
        char name[N];
        printf("/*****************************************************/\n");
        printf("/******************* 1.StudentID *********************/\n");
        printf("/******************* 2.StudentName *******************/\n");
        printf("/******************* 3.StudentAge ********************/\n");
        printf("/******************* 4.StudentSex ********************/\n");
        printf("/*****************************************************/\n");
        printf("Please input what you want to search:");
        scanf("%d",&n);
        while((n > 4) || (n < 1))
        {
            printf("Your input must be 1-4!\n");
    	printf("Please input again:");
    	scanf("%d",&n);
        }
        if(n == 1)
        {
            printf("Please input StudeentID you want to search:");
    	scanf("%d",&info);
    	mysearch(head,1,info);
        }
        if(n == 2)
        {
            printf("Please input StudeentName you want to search:");
    	scanf("%s",name);
    	mysearch(head,2,name);
        }
        if(n == 3)
        {
            printf("Please input StudeentAge you want to search:");
    	scanf("%d",&info);
    	mysearch(head,3,info);
        }
        if(n == 4)
        { 
            printf("Please input StudeentSex you want to search:");
    	scanf("%d",&info);
    	mysearch(head,4,info);
        }
        #endif
        printf("Press Enter To Continue...");
        getchar();
        getchar();
    }
    
    
    void display(NODE *head)
    {
        int choose;
        while(1)
        {
            system("clear");
            printf("/****************Student Manage System****************/\n");
            printf("/******************* 1.Look Over *********************/\n");
    	printf("/******************* 2.Add Student *******************/\n");
    	printf("/******************* 3.Delete Student ****************/\n");
    	//printf("/******************* 4.Sort **************************/\n");
    	printf("/******************* 4.Search ************************/\n");
    	printf("/******************* 5.Exit **************************/\n");
    	printf("/*****************************************************/\n");
    	printf("Please Input Your Choose:");
    	scanf("%d",&choose);
    	while((choose > 5) || (choose < 1))
    	{
    	    printf("Your Choose Must Be 1 To 5!\n");
    	    printf("Please Input Your Choose Again:");
    	    scanf("%d",&choose);
    	}
    	switch(choose)
    	{
    	    case 1:
    	    {
    	        system("clear");
    	        lookover(head);
    	        break;
    	    }
    	    case 2:
    	    {
    	        system("clear");
    	        addstudent(head);
    	        break;
    	    }
    	    case 3:
    	    {
    	        system("clear");
    	        deletestudent(head);
    	        break;
    	    }
    	    case 4:
    	    {
    	        system("clear");
    	        searchinfo(head);
    	        break;
    	    }
    	    case 5:
    	    {
    	        system("clear");
    	        exit(-1);
    	    }
    	    default:
    	    {
    	        break;
    	    }
    	}
    
        }
    }
    


    main.c:

    #include "StudentManage.h"
    
    int main()
    {
        NODE *head = mycreate();
        STUDENT stu1,stu2,stu3,stu4;
        SCORE sc1,sc2,sc3,sc4;
        stu1.studentID = 12001;
        strcpy(stu1.name,"王明");
        stu1.age = 18;
        stu1.sex = 1;
        sc1.chinese = 90;
        sc1.math = 91;
        sc1.english = 92;
        sc1.average = 91;
        sc1.total = 273;
        stu2.studentID = 12002;
        strcpy(stu2.name,"张芳");
        stu2.age = 19;
        stu2.sex = 0;
        sc2.chinese = 80;
        sc2.math = 81;
        sc2.english = 82;
        sc2.average = 81;
        sc2.total = 243;
    
        stu3.studentID = 12003;
        strcpy(stu3.name,"李强");
        stu3.age = 19;
        stu3.sex = 1;
        sc3.chinese = 70;
        sc3.math = 71;
        sc3.english = 72;
        sc3.average = 71;
        sc3.total = 213;
    
        stu4.studentID = 12004;
        strcpy(stu4.name,"张小雨");
        stu4.age = 20;
        stu4.sex = 0;
        sc4.chinese = 60;
        sc4.math = 61;
        sc4.english = 62;
        sc4.average = 61;
        sc4.total = 183;
    
        head = myinsert(head,&stu1,&sc1);
        head = myinsert(head,&stu2,&sc2);
        head = myinsert(head,&stu3,&sc3);
        head = myinsert(head,&stu4,&sc4);
        display(head);
    }
    



    有一个bug,删除里第一个学生之后,myprint会无限不停输出剩下的学生~~~~~~

    展开全文
  • 下面使用内核链表完成基本的增删改查,实现简易的学生信息管理系统,拥有保存信息到txt文本的功能,和从txt中读取信息的功能。(内核链表的头文件可以百度直接下载) #include"kernel_list.h" //内核链表的头,只...

    内核链表

      我们知道,内核链表是双向链表,在这里不详细介绍内核链表的概念,只列出demo并附上注释供需要的同学参考。

    下面使用内核链表完成基本的增删改查,实现简易的学生信息管理系统,拥有保存信息到txt文本的功能,和从txt中读取信息的功能。(内核链表的头文件可以百度直接下载)

    #include"kernel_list.h"    //内核链表的头,只需加入内核链表的c文件,一起编译即可运行该程序
    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    #include<sys/stat.h>    //fopen函数
    #include<fcntl.h>        
    
    //结构体
    typedef struct list{
    
    char name[20]; //名字
    int score; //分数
    int classs; //班级
    struct list_head mylist; //内核链表中特有的小结构体,
    
    }Node;    //结构体别名,结构体的详细使用在上一篇已介绍
    
    //初始化链表
    Node *init_list(Node* head)
    {
        head=malloc(sizeof(Node)); //为head向内存申请空间
        if(head == NULL){
        perror("head");    //如果出错,输出错误信息
        exit(1);
        }
        INIT_LIST_HEAD(&(head->mylist));    //内核链表初始化
    
        return head;    //返回头节点
    }
    
    //增(尾插)
    int insert_tail(Node* head,char *name,int score,int classs)
    {
        Node* new=malloc(sizeof(Node));    //为新增的节点分配内存
        if(new == NULL)
        {
            perror("new");
            exit(2);
        }
        strcpy(new->name,name);    //name是数组,所以不能直接赋值,使用strcpy函数
        new->score=score;
        new->classs=classs;
    
        list_add_tail(&(new->mylist),&(head->mylist));    //内核链表尾插
    
        return 0;
    }
    
    //删
    int delete_node(Node* head,char *name)
    {
        Node* p = NULL;
        list_for_each_entry(p,&(head->mylist),mylist)    //内核链表遍历
        {
            if(!strcmp(p->name,name))     //字符串比较函数,如果有相同返回0
            {         
                list_del(&p->mylist);        //内核链表删除
                printf("%s is delete finsh!\n",name);
                return 0;
            }else 
                printf("没有这个名字\n");
            return 0;
        }
     
    return 0;
    }
    
    //查
    int find_node(Node* head,char *data)
    {
    
        Node* p=NULL;        //定义一个结构体指针,指向空
        list_for_each_entry(p,&(head->mylist),mylist)        //内核链表遍历
        {
        if(!strcmp(p->name,data)){            //字符串比较函数,如果有相同返回0
            printf("you find name is %s\n",data);
            printf("name is %s,score is %d,class is %d\n",p->name,p->score,p->classs);
            return 0;
        }else
            printf("查不到这个名字\n");
        return 1;
    
        }
    
    return 0;
    
    }
    
    //显示当前信息
    int show_list(Node* head)
    {
        Node* p = NULL;
        list_for_each_entry(p,&head->mylist,mylist)
        {
            printf("name is %s,score is %d,class is %d\n",p->name,p->score,p->classs);
    
        }
        return 0;
    }
    
    //保存信息到txt
    int save_node(Node* head)
    {
        FILE *fp;
        Node *p=NULL;
        if((fp=fopen("student.txt","w+"))==NULL){    //w+表示,如果存在就清空,不存在就创建
            perror("open");
        }
        list_for_each_entry(p,&(head->mylist),mylist)
        {
            fprintf(fp," %s %d %d ",p->name,p->score,p->classs);    //将信息写入txt中
        }
    
        fclose(fp);    //使用完关闭
        return 0;
    
    }
    
    //从txt中读取文件信息,并打印到屏幕
    int load_node(Node* head)
    {
        char name[20];
        int score;
        int classs;
    
        FILE *fp;
        if((fp=fopen("student.txt","r"))==NULL){
            perror("open");
        }
    
        Node*p=malloc(sizeof(Node));
        //Node*p=NULL;
        list_for_each_entry(p,&(head->mylist),mylist){
            fscanf(fp,"%s %d %d ",p->name,&(p->score),&(p->classs));    //从txt中读出信息到链表结构
            printf("name is %s,score is %d,class is %d\n",p->name,p->score,p->classs);
        }
    
        fclose(fp);
    
        return 0;
    } 
    
    
    
    int main()
    {
        Node* list=init_list(list);//初始化空链表函数
        char name[20];
        int score;
        int classs;
        int num,count=1;
        int ret;
        int j=1;
        char value[30] = {0} ;
        char *pA;
    
        while(1)
        {
    
            puts("***********主菜单**********");
            puts("-------1:增加学生信息------");
            puts("-------2:显示学生信息------");
            puts("-------3:删除学生信息------");
            puts("-------4:查找学生信息------");
            puts("-------5:保 存 信  息------");
            puts("-------6:读 取 信  息------");
            puts("-------7:退 出 系  统-------");
            puts("***************************");
            printf("请输入对应选项:");
            scanf("%d",&num);
            switch(num)
            {
    			case 1:
    			while(count)
    			{
    				puts("-------1:输入信息----------");
    				puts("-------2:返回上一层--------");
    				printf("请输入对应选项:");
    				scanf("%d",&num);
    				switch(num)
    				{
    					case 1:
    					printf("请输入学生姓名: ");
    					scanf("%s",name);
    					printf("请输入学生分数: ");
    					scanf("%d",&score);
    					printf("请输入学生班别: ");
    					scanf("%d",&classs);
    
    					insert_tail(list,name,score,classs);
    
    					break;
    
    					case 2:
    					count=0;
    					break;
    
    					default:
    					printf("对不起,没有这个选项,请重新选择:\n");
    					continue;
    					break;
    
    				}
    			}
    			break;
    
    			case 2:
    			show_list(list);
    			break;
    
    			case 3:
    			pA= &value[0];  
    			printf("请输入你要删除的学生名字:\n");
    			scanf("%s",value);       
    			while(getchar() != '\n');  //清空输入缓冲
    			while(*pA != '\0')  
    			{
    				if( *pA >= 'a' && *pA <= 'z')
    				{
    					delete_node(list,value);
    					break;
    				}
    				else 
    				{
    					printf("input Error !\n");
    					break;
    				}
    
    				pA++;
    			}
    			break;
    
    			case 4:
    			while(j)
    			{
    				pA= &value[0];  
    				printf("请输入你要查找的学生名字:\n");
    				scanf("%s",value);       
    				while(getchar() != '\n');  //清空输入缓冲
    				while(*pA != '\0')  
    				{
    					if( *pA >= 'a' && *pA <= 'z')
    					{
    						ret=find_node(list,value);
    						if(ret==0){
    							j=0;
    						}       
    						break;
    					}else {
    						printf("input Error !\n");
    						break;
    					}
    
    
    					pA++;
    				}
    			}
    			break;
    
    			case 5:
    			save_node(list);
    			break;
    
    			case 6:
    			load_node(list);
    			break;
    
    			case 7:
    			printf("bye,see you!\n");
    			exit(0);
    
    			default:
    			printf("对不起,没有这个选项,请重新选择:\n");
    			continue;
    			break;
    		}
        }
    
        
    	return 0;
     
    }

    因为工作比较忙csdn不是经常上,如果大家有任何疑问或者找我聊技术唠唠嗑,欢迎加我微信a5230gxkd交流,一起进步,或者在我的公众号底下留言,我会第一时间回复

    展开全文
  • //修改学生信息 bool alter_grades(listnode head,listnode newOne) { int id_num,grade,subject,judgeStu,teaSubject = 0; printf("please input the student's id_num :"); scanf("%d",&id_num); while...

    这篇博客承接上一篇(https://blog.csdn.net/qq_41861442/article/details/99077592)加入了文件IO,每个简单程序都会面临这样的问题,数据无法保存,再次进入,数据全没了,那么我们就需要运用到文件IO的知识了,(没有数据库,bro)

    在这里插入代码片#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 true;
    }
    
    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,若匹配,返回true
    listnode login_in(listnode head,listnode newOne)
    {
    	int passwdInput,id_num;
    	listnode new = head;
    	printf("please input your id_num(five Number): ");
    	if(scanf("%d",&(id_num)) == 1)
    	{
    		while(getchar() != '\n');
    		listnode tmp = search_member_prev(head,id_num);
    	    if(tmp != NULL)
    		{
    			printf("please input your password :");
    			scanf("%d",&passwdInput);
    			while(getchar() != '\n');
    			if(tmp->next->passwd == passwdInput)
    			{
    				newOne = tmp;
    				return newOne;
    			}
    		}
    	}
    	return NULL;
    }
    
    int JudgeStuTea(listnode head ,listnode newOne)
    {
    	printf("1");
    	int number = newOne->next->id_num ;
    	listnode tmp = search_member_prev(head,number);
    	if( tmp->next->status == 't')
    	{
    		printf("this is a teacher\n");
    		return 1;
    	}
    	else
    		return 0;
    }
    
    void show_grade(listnode newOne)
    {
    	printf("                                     %d \n",         newOne->next->id_num);
    	printf("                                     chinese : %d\n",newOne->next->chinese);
    	printf("                                     math    : %d\n",newOne->next->math);
    	printf("                                     English : %d\n\n",newOne->next->English);
    }
    //修改密码
    bool alter_passwd(listnode newOne)
    {
    	char Judge;
    	int passwd;
    	printf("your password : %d\n",newOne->next->passwd);
    	printf("You are sure about changing Your pasword ? y/n : \n");
        scanf("%c",&Judge);
    	while(getchar()!='\n');
    	if(Judge == 'y')
    	{
    		printf("please input your new password :\n");
    		scanf("%d",&passwd);
    		newOne->next->passwd = passwd;
    		printf("%d\n",newOne->next->passwd);
    	    return true;
    	}
    	else
    	{
    		printf("don't waste my time , bitch !\n");
    		return false;
    	}
    }
    
    //学生操作
    void StuMove(listnode head , listnode newOne)
    {
    	int numberOption;
    	while(1)
    	{
    		printf(" hello ,%d \n",newOne->next->id_num);
    		printf(" press 0 : show your all grade \n\n");
    		printf(" press 1 : alter your passwd \n\n\n");
    		printf(" press 2 : exit\n\n");
    		printf(" Your option : \n");
    		scanf("%d",&numberOption);
    		while(getchar() != '\n');
    		switch(numberOption)
    		{
    			case 0:
    			    show_grade(newOne);
    				break;
    			case 1:
    			    alter_passwd(newOne);
    				break;
    			case 2:
    			    info_save( head );
    		}
    	}
    }
    
    //打印所有的成员信息
    void show_all(listnode head)
    {
    	listnode tmp = head;
    	printf("\tI\tS\tC\tM\tE\tA\t\tSEX\n\n");
            while(tmp->next != NULL)
    	{
    	
    		printf("\t%d\t%c\t%d\t%d\t%d\t%s\t%c\t\n\n",tmp->next->id_num,tmp->next->status,tmp->next->chinese,tmp->next->math ,tmp->next->English ,tmp->next->address,tmp->next->sex);
    	    tmp = tmp->next;
    	}
    }
    
    listnode add_grades(listnode head)
    {
    	listnode tmp = head;
    	char addressInput[20];
    	
    	while(tmp->next != NULL)
    	{
    		tmp = tmp->next;
    	}
    	listnode new  = malloc(sizeof(struct node));
    	printf("\n\n");
    	printf("please input the student 's id : ");
    	scanf("%d",&(new->id_num));
    	while(getchar() != '\n');
    	printf("\n\n");
    	new->status = 's';
    	printf("please input the student 's chinese : ");
    	scanf("%d",&(new->id_num));
    	while(getchar() != '\n');
    	printf("\n\n");
    	printf("please input the student 's math : ");
    	scanf("%d",&(new->math));
    	while(getchar() != '\n');
    	printf("\n\n");
    	printf("please input the student 's English : ");
    	scanf("%d",&(new->English));
    	while(getchar() != '\n');
    	printf("\n\n");
    	printf("please input the student 's passwd : ");
    	scanf("%d",&(new->passwd));
    	while(getchar() != '\n');
    	printf("\n\n");
    	printf("please input the student 's address : ");
    	gets(addressInput);
    	strcpy(new->address,addressInput);
    	printf("\n\n");
    	printf("please input the student 's sex : ");
    	scanf("%c",&(new->sex));
    	while(getchar() != '\n');
    	tmp->next = new;
    	show_all(head);
    	return head;
    }
    
    //修改学生信息
    bool alter_grades(listnode head,listnode newOne)
    {
    	int id_num,grade,subject,judgeStu,teaSubject = 0;
    	printf("please input the student's id_num :");
        scanf("%d",&id_num);
    	while(getchar() != '\n');
    	listnode tmp = search_member_prev(head ,id_num);
    	//根据id_num在学生列表中匹配学生,若匹配成功,且该id_num不是一个老师 tmp->next->status != 't'
    	//则进行下一步操作
    	if( ( tmp != NULL ) && (tmp->next->status != 't'))
    	{
    		printf("is he this guy ?(y:1,n:0)\n");
    		show_grade(tmp);
    		scanf("%d",&judgeStu);
    		while(getchar()!='\n');
    		if(judgeStu == 1)
    		{
    			//这里匹配登陆账号老师是教哪一科的,从而修改具体学生哪一科的成绩
    			if(newOne->next->math == -1)
    			{
    				printf(" how much about math : ");
    				scanf("%d",&(tmp->next->math));
    				show_grade(tmp);
    				return true;
    			}
    			else
    			    if(newOne->next->chinese == -1)
    			{
    				printf(" how much about chinese : ");
    				scanf("%d",&(tmp->next->chinese));
    				show_grade(tmp);
    				return true;
    			}
    			else 
    				if(newOne->next->English == -1)
    			{
    				printf(" how much about English : ");
    				scanf("%d",&(tmp->next->English));
    			    show_grade(tmp);
    				return true;
    			}
    				
    		}
    	}
    	return false;
    	
    }
    
    //学生删除操作 参数:一个listnode 的头节点
    void student_delete(listnode head)
    {
    	int id_number,judgeStu;
    	listnode tmp = head;
    	listnode disap;
    	printf("who , delete :");
    	scanf("%d",&id_number);
    	//根据输入寻找学生,
    	tmp = search_member_prev(head ,id_number);
    	if(tmp != NULL)
    	{
    		printf("is he this guy ?(y:1,n:0)\n");
    		show_grade(tmp);
    		scanf("%d",&judgeStu);
    		if(judgeStu == 1)
    		{
    			disap = tmp->next;
    			tmp->next = tmp->next->next;
    			free(disap);	
    			show_all(head);
    			printf("delete student successfully");
    		}
    		else
    		{
    			printf("delete failed");
    		}
    	}
    }
    
    
    //老师操作选项
    //根据输入选择老师可以进行的功能
    void TeaMove(listnode head,listnode newOne)
    {
    	int options;
    	while(1)
    	{
    		printf(" welcome , %d",newOne->next->id_num);
    		printf(" press 0 : change your passwd\n");
    		printf(" press 1 : show the all grades\n");
    		printf(" press 2 : alter one student's grades\n");
    		printf(" press 3 : delete one student\n");
    		printf(" press 4 : add one student\n");
    		printf(" press 5 : exit\n\n");
    		scanf("%d",&options);
    		while(getchar()!= '\n');
    			switch(options)
    			{
    				case 0:
    					alter_passwd(newOne);
    					break;
    				case 1:
    					show_all(head);
    					break;
    				case 2:
    					alter_grades(head,newOne);
    					break;
    				case 3:
    					student_delete(head);
    					break;
    				case 4:
    				    head = add_grades(head);
    					break;
    				case 5:
    				    info_save( head );
    			}
    		}
    }
    
    void info_save( struct node *head )
    {
            int number = 0;
            int i = 0 ;
            struct node *tmpSave;
            int ret;
            FILE *fp = fopen("./stuInfo.txt","w+");
            if(fp == NULL)
    	{
    		perror("fopen stuInfo.txt error");
    		return -1;
    	}
    	else
            {
    		printf("fopen stuInfo.txt succeed\n");
    	}   
    	listnode tmp = head;
    	while(tmp->next != NULL)
    	{
    	    number++;	
    	    tmp = tmp->next;
    	}
            tmp = head;
            printf(" head : %d\n",number);
             tmpSave = tmp->next;
            for( i = 0 ; i < number ; i++ )
            {
                
                ret = fwrite(tmpSave,sizeof(struct node),1,fp);
                tmpSave = tmpSave->next; //fseek(fp,sizeof(struct node),SEEK_CUR);
            }
          //  printf(" end : %d\n",);
            fclose(fp);    
            exit(0);
    }
    
    int main()
    {
            FILE *fp = fopen("./stuInfo.txt","r");
            if(fp == NULL)
    	{
    		perror("fopen stuInfo.txt error");
    		return -1;
    	}
    	else
            {
    		printf("fopen stuInfo.txt succeed\n");
    	}
            int sizeOfStru = sizeof(struct node);
            long sizeOfTXT ;
           
            int struNumber;//stru number
            if( fseek(fp,0,SEEK_END) == -1 )
            {
                perror(" set seek failed\n");
                return -1;
            }//get the size of txt  
            else
                sizeOfTXT = ftell(fp);
            printf(" number :%ld\n",sizeOfTXT);
            rewind(fp);
         
        
            struNumber =(int) (sizeOfTXT/sizeOfStru);// get how many strus
          
            int i,ret;
            printf(" fp : %ld\n",ftell(fp));
    	listnode head = listnode_init();
            struct node tmp;
            printf(" struNUmber : %d\n",struNumber);
            for( i = 0 ; i < struNumber ; i++ )
            {
              
                ret = fread(&tmp,sizeOfStru,1,fp);
                if( ret == 0 )
                    perror("fread txt file error\n");
                add_node(head,tmp.id_num,tmp.status,tmp.chinese,tmp.math,tmp.English,tmp.passwd,tmp.address,tmp.sex);
                printf(" fp : %ld\n",ftell(fp));
            }
            fclose(fp);
    	//先插入几个学生和老师的信息
           
            /*
    bool add_node(listnode head,int id_num,char status,int chinese,int math ,int English , int passwd,char * address,char sex)
    {
    	add_node(head,20161,'t',-1,0,0,123456,"hubeijinghzou",'w');
    	add_node(head,20162,'t',0,-1,0,123457,"hubeiwuhan",'m');
    	add_node(head,20163,'t',0,0,-1,123458,"hubeixiaogan",'m');
    	add_node(head,20164,'s',59,60,61,123459,"hubeijingzhou",'w');
    	add_node(head,20165,'s',79,73,77,123450,"hubeijingzhou",'m');
    	add_node(head,20166,'s',99,83,87,223450,"hubeijingzhou",'m');
            */
    	//验证登陆信息
    	listnode newOne = head->next;
    	if(struNumber == 0)// if no member in txt , aumotically add a teacher information
            {
    	    add_node(head,20161,'t',-1,0,0,123456,"hubeijinghzou",'w');
            }
            while(1)
    	{
    		newOne = login_in(head,newOne);
    		if(newOne != NULL)
    			break;
    	}
    	//欢迎界面
    	printf("welcome to zhangke's school info manage system :\n\n");
    	//进行判断,如果是老师,进入 TeaMove
    	//如果是学生,进入StuMove
    	if( JudgeStuTea(head,newOne) == 1 )
    		TeaMove(head,newOne);
    	else
    		StuMove(head,newOne);
    	
    }
    
    

    1数据读取部分,我们需要读取目标文件(我们数据存储的地方)的内容,有的话就读取到链表中,没有就自动先插入一个成员信息(用作登陆),
    2最重要的部分:我们思考问题的时候尽量把问题简化,我们做这个系统如果每项功能都需要需要进行数据读取以及写入的话,那么我们的工作量就会急剧增加,这些数据我们函数运行的时候全部读取并放入到链表中,数据的增删改查结束后,再一次性全部写入到文件当中,这样在处理较小的数据量时,这样对我们的功能要求低一点

    展开全文
  • 写在前面 在看Linux源码时,经常会涉及到驱动和设备的匹配,如果想弄清楚匹配过程,就要理解双向循环链表。...首先定义一个结构体,存放学生信息 struct student { int number; char id[20];
  • JAVA双向链表:实例

    2020-07-08 22:58:46
    //学生信息管理系统双向链表实例) public class Dome_main { public static void main(String[] args) { // TODO Auto-generated method stub Iand i = new Iand(); CaoZuo c = new CaoZuo(); Scanner ...
  • 关于C结构体和单向链表的一个小demo完全是命令行的,估计大二的时候会让写一个关于链表和结构体的东西,这里记录一下,之前写过一个双向循环链表的,这里就不贴了,原理都差不多,多了一个指针而已逻辑是最重要的,逻辑是...
  • 这个通讯录管理系统是我5月份对于C语言和数据结构复习做的一个小项目和总结,后来这几天对数据库起了兴趣自己又重新补上了数据库(MySQL)的部分,让通讯录管理系统真正地可以存储数据。 基于自己还是大学生的关系,...
  • 环境:linux VI环境 采用双向链表实现多角色(管理员,教师,学生)对学生,教师信息的修改 数据库:文件
  • 这是我个人写的一个学生管理系统,这是我仅仅用来练手的代码,要知道链表可是你在面试过程中最大机率会考到的,我是陆续从单向链表入门,然后采用双向链表写的代码!如有BUG,请指正,让我们共同进步! 1 #include&...
  • 学生成绩管理系统

    2011-12-14 21:45:51
    该程序是双向链表和文件操作结合的学生成绩管理系统。 可从文件中读取显示信息,并插入新的信息到文件中,删除数据。 程序模块独立,结构清晰,从main函数入手可很快读懂程序思路。 压缩包内含有读取信息文件,编译...
  • 摘 要:本课程设计设计一个实用的小型通讯录管理系统,用文件来存储学生的姓名、电话、QQ号码、邮编、地址等信息,完成对信息的添加、删除、查询、显示所有信息,退出及用双向链表来处理修改等操作。 在本课程设计中,...
  • 学生管理系统也只是简单的使用文件作为数据的存储方式,用户登录时将文件中的信息加载到双向链表中,然后对链表进行增删改查的操作。  本文讨论的重点,在于用户界面的生成。和很多以界面为重点的项目开发类似,...
  • 自写信息管理系统——C实现

    千次阅读 2016-06-29 21:15:32
    信息管理系统 简介: 该管理系统分为三个权限:学生,老师,管理员 用双向链表实现,文件储存,有账号密码功能。 密码实现MD5加密,较难破解 实现了链表添加,查找,排序,删除等基本操作 共分为6个文件 5个.cpp文件...
  • 信息管理系统 简介: 该管理系统分为三个权限:学生,老师,管理员 用双向链表实现,文件储存,有账号密码功能。 密码实现MD5加密,较难破解 实现了链表添加,查找,排序,删除等基本操作 管理员能够管理学生...
  • 成绩管理系统.cpp

    2019-10-08 20:12:16
    C语言,双向链表实现,从文件读取信息,及格和不及格学生分在两个链表中,具有创建链表、显示、删除、插入、更新补考信息、查找的功能
  • c++/报告(报告内含代码)本次三级项目是开发一个人员信息管理系统,用于管理学生及教师的相关信息,具备查询、统计、添加、删除等功能,需用双向链表实现,理解并、交、差操作并不影响参与操作的集合,实现并交差...
  • 线性表的基本操作

    2011-12-23 09:14:54
    利用链式存储结构存储学生的成绩信息,设计一个学生成绩管理系统,具有以下功能: (1)定义学生结构体类型struct Student,每个学生包括学号、姓名、3门功课(课程名自己定义)、总分。 (2)建立双向循环链表:...
  • 设计一个实用的小型通讯录管理系统,用文件来存储学生的姓名,街道,城市,邮编,国家等信息,完成对信息的添加,删除,查询,显示所有信息,退出及用双向链表来处理修改等操作。
  • C++三级项目.zip

    2019-06-10 16:14:03
    随着C++面向对象程序设计课程的进行,为了能够将所学知识应用于实际情况中,我们开发了一个在校人员管理系统,该系统利用双向链表建立队列和堆栈,将学生和教师的信息分别存储在队列和堆栈中进行各种功能的实现,...
  • 2.2.4 循环链表和双向链表 25 2.3 栈和队列 27 2.3.1 栈 28 2.3.2 队列 32 2.4 串和数组 38 2.4.1 串 38 2.4.2 数组 41 习题 44 第3章 非线性数据结构 3.1 树及其基本概念 46 3.2 二叉树 47 ...
  • 《数据结构 1800题》

    热门讨论 2012-12-27 16:52:03
    双向链表 11.在下面的程序段中,对 x的赋值语句的频度为(C )【北京工商大学 2001 一、10(3分)】 FOR i:=1 TO n DO FOR j:=1 TO n DO x:=x+1; A. O(2n) B.O(n) C.O(n2) D.O(log2n) 12.程序段 ...
  • 实例088 创建双向链表 114 实例089 创建循环链表 117 实例090 双链表逆置 118 实例091 双链表逆序输出 120 实例092 约瑟夫环 122 实例093 创建顺序表并插入元素 123 实例094 向链表中插入结点 125 ...
  • 实例172 事务在插入多表学生信息数据中的应用 实例173 在添加多条供求信息数据中设置事务的保存点 实例174 存储过程级别事务在会员基本信息注册中的应用 6.2 新型事务:System.Transactions事务性编程模型 实例...

空空如也

空空如也

1 2 3 4
收藏数 63
精华内容 25
关键字:

双向链表学生信息管理系统