思路:创建单链表,将随机函数生成的表示单链表的值,用mod 2 判断是否是偶数,若不是加1使其变成偶数,在mian函数中,每次输出10个节点输出一个‘\n’
# include <stdio.h>
# include <stdlib.h>
# include <time.h>
struct chain
{
int value;
struct chain *next;
};
struct chain *create()
{
struct chain *head ,*tail,*p;
int n, i,x;
head = tail =NULL;
printf("Enter a number n : ");
scanf("%i",&n);
srand((unsigned)time(NULL));
for (i = 0;i < n;i++)
{
p = (struct chain *)malloc(sizeof(struct chain));
x = rand()%100+1;
if ( x % 2!=0)
x +=1;
p->value = x;
if (head == NULL)