main.c
来自「数据结构自己写的双向链表的实现」· C语言 代码 · 共 59 行
C
59 行
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "main.h"#include "list.h"void print(DataType data){ printf("num=%5d \t name= %s\n",data.num,data.name);}int insert(DataType old,DataType new){ if(new.num < old.num) return 1; else return 0;}int delcond(DataType data){ if (4 == data.num) return 1; else return 0;}void freedata(DataType data){ ;//free(data.name);}int main(int argc,char **argv){ int i; DataType stu; List *li; li = Create_List(); for(i=0;i<4;i++) { stu.num = i*2; stu.name = malloc(sizeof(char)*10); printf("pls enter students name:\n"); scanf("%s",stu.name); Add_Node(li,stu); } printf("--------------new list ----------\n"); Print_List(li,print); DataType newdata; newdata.num = 3; newdata.name =malloc(sizeof(char)*10); strcpy(newdata.name,"zhangsan"); Insert_Node(li,insert,newdata); printf("--------------after insert ----------\n"); Print_List(li,print); Delete_Node(li,delcond,freedata); printf("--------------after del ----------\n"); Print_List(li,print); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?