list

来源:互联网 发布:php开发实战1200例pdf 编辑:程序博客网 时间:2024/06/06 10:58

pointers on c 

里面的简单的单项链表……发现自己现在太弱了……

#include <stdio.h>#include <stdlib.h>typedef struct NOED{    struct NOED *link;    int value;} Node;Node a;intsll_insert(register Node **linkp, int new_value){    register Node *current;    register Node *new;    while ((current = *linkp) != NULL && current->value < new_value)linkp = ¤t->link;    new =(Node *)malloc(sizeof(Node));    if (new == NULL)return 0;    new->value = new_value;    new->link = current;    *linkp = new;    return 1;}    intmain(){    int n, i, x;    scanf("%d", &n);    Node *root;    Node a;    root = &a;    for (i=0; i<n; i++)    {scanf("%d", &x);sll_insert(&root, x);    }}

哎……一切都慢慢来……不过不知道我该怎么往下发展……难道是水题么!

原创粉丝点击