敲代码 学调试 基本的啊

梅尚程荀
马谭杨奚
2012-03-08 13:21
2012-03-08 13:25
程序代码:struct Node{
int data;
struct Node *next;
}linklist;
linklist: 代表的意思 strcut Node linklist;
2012-03-08 16:25
2012-03-08 16:43
2012-03-08 20:31
2012-03-08 21:06
2012-03-08 21:23
程序代码:#include<stdio.h>
#include<stdlib.h>
typedef struct node{
int data;
struct node *next;
};
typedef struct node linklist;
linklist *creast(int n);
void scan(linklist *h);
linklist *delete(linklist *h);
int main(){
int n,i;
linklist *h;
h=(linklist*)malloc(sizeof(struct node));
printf("Please input the n:");
scanf("%d",&n);
h=creast(n);
for(i=0;i<n;i++){
scan(h);
h=delete(h);
}
return 0;
}
linklist *creast(int n){
int i;
linklist *p,*h;
printf("Please input the %d numbers:",n);
h=(linklist*)malloc(sizeof(struct node));
h->next=NULL;
for(i=0;i<n;i++){
p=(linklist*)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next=h->next;
h->next=p;
}
return h;
}
void scan(linklist *h){
linklist *m;
if(h=NULL) printf("Empty List!\n");
m=(linklist*)malloc(sizeof(struct node));
m=h->next;
while(m){
printf("%d\t",m->data);
m=m->next;
}
}
linklist* delete(linklist *h){
linklist *q;
q=h->next;
h->next=h->next->next;
free(q);
return h;
}我花了一晚上,把程序改成这个样子了,可是还是有错哇
2012-03-08 22:19
我连这个都看不懂呢
2012-03-08 23:14