每次到12就结束了为什么
#include <stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct pupil)
struct pupil
{
int number;
struct pupil *next;
};
void main(int argc, char *argv[])
{
int count = 0, i = 0;
struct pupil *p1, *p2, *head;
head = p2 = p1 = (struct pupil*)malloc(LEN);
p1->number = count + 1;
count++;
while (count < 13)
{
if (count == 12)
{
p1 = (struct pupil*)malloc(LEN);
p1->next = head;
p1->number = count + 1;
p1 = head;
break;
}
p1 = (struct pupil*)malloc(LEN);
p2->next = p1;
p2 = p1;
p2->number = count + 1;
count++;
}
count = 0;
while (i<12)
{
if (p1->number!=0)
{
count++;
if (count % 3 == 0)
{
printf_s("出来的是%4d\n", p1->number);
p1->number = 0;
i++;
}
}
p1 = p1->next;
}
system("pause");
}