# include <stdio.h>
# include <stdlib.h>
# include <malloc.h>
struct node
{
int num;
struct node *next;
};
void creat(struct node *head,int n)
{
struct node *p,*q;
struct node *scanf;
randomize();
q=head;
head->num=random(10);
scanf=head;
while(--n)
{
p=(struct node *)malloc(sizeof(struct node));
p->num=random(10);
q->next=p;
q=q->next;
while(scanf != p)
{ //
while(scanf->num == p->num) //
{ /主要
p->num=random(10); //
scanf=head; //
} //
scanf=scanf->next; //
}
scanf=head;
}
p->next->next=NULL; //自已还没看懂 改成p->next=NULL为啥少了个
}
void output(struct node *head)
{
while(head->next!=NULL)
{
printf("%d\t",head->num);
head=head->next;
}
}
int main()
{
struct node *head;
creat(head,10);
output(head);
getch();
}