单链表基础

来源:互联网 发布:信息工程研究所 知乎 编辑:程序博客网 时间:2024/06/14 09:54

建立:

#include <iostream>#include <stdio.h>#include <string.h>#include <conio.h>using namespace std;typedef struct student{    int data;    struct student *next;}node;node* create(int N){    node *head,*p,*s;    int i = 0;    head = (node*)malloc(sizeof(node));    p = head;    p->data = 1;    for(i = 2; i <= N; i++)    {        s = (node*)malloc(sizeof(node));        p->next = s;        s->data = i;        p = s;    }    p->next = NULL;    return head;}
0 0
原创粉丝点击