69,371
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<malloc.h>
typedef struct s1
{
int data;
struct s1* next;
} NODE;
push(NODE* head,int value)
{
NODE* tmp=head;
head=(NODE*)malloc(sizeof(NODE));
head->data=value;
printf("%d",head->data);
head->next=tmp;
}
print(NODE* head)
{
NODE* itNode=head;
while(itNode)
{
printf("%d\n",itNode->data);
itNode=itNode->next;
}
}
int main(void)
{
int i;
NODE* mylist=0;
for(i=1;i<10;++i)
push(mylist,i);
print(mylist);
return 0;
}
改一下