16,550
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Node
{
int N;
struct Node *next;
};
void main()
{
struct Node *cc,*q,*head = NULL;
//cc=q= (struct Node *)malloc(sizeof(struct Node));
int a=0;
do
{
cc= (struct Node *)malloc(sizeof(struct Node));
cc->N=a;
cc->next = NULL;
if(head == NULL)
head = q = cc;
else
q->next = cc;
q = cc;
a++;
}while (a<5);
// q->next =NULL;
for(q = head; q!=NULL; q=q->next)
{
printf("%d ",q->N);
}
putchar('\n');
}