急呀。。高手进。。。c语言程序。。。。

来源:百度知道 编辑:UC知道 时间:2024/05/17 10:54:24
#include<stdio.h>
#include<malloc.h>

typedef struct node
{int data;
struct node*next;
}NODE;

NODE*creatlink1()
{
int a[N];

NODE*head,*s;
int i;
head=(NODE*)malloc(sizeof(NODE));
head->next=NULL;
printf("please ensure the length of the list:") ;
scanf ("%d",&A[N-1]);
for(i=N-1;i>=0;i--)
{s=(NODE*)malloc(sizeof(NODE));
s->data=a[i];
s->data=head->data;
head->data=s;
scanf("%d",&a[i]);
}
return head;
}
void main()
{
NODE p;
for(p=creatlink1();p=!NULL;p=p->next)
prinf("%d/n",p->data);
}
这个一个创建单表的程序,谁能帮我改下。。。。
满意的话追加。。。

NODE*creatlink1()
{
int n;

NODE*head,*s;
int i;
head=(NODE*)malloc(sizeof(NODE));
head->next=NULL;
printf("please ensure the length of the list:") ;
scanf ("%d",&n);
for(i=1;i<n;i++)
{s=(NODE*)malloc(sizeof(NODE));
printf("%d. data of the list: ",i);
scanf("%d", &(head->data));// read data

s->next=head;
head=s;
}
printf("%d. data of the list: ",i);
scanf("%d", &(head->data));// read last data

return head;
}

#include<stdio.h>
#include<malloc.h>
#define N 100

typedef struct node
{
int data;
struct node*next;
}NODE;

NODE*createlink1()
{
int n;
NODE*head,*s,*p;

head=(NODE*)malloc(sizeof(NODE));
head->next=NULL;
p=head;
printf("please ensure t