关于单链表
#include "stdio.h"#include "stdlib.h"
#define n 8
typedef struct max
{int num;
struct max *next;
}DT;
DT *create()
{int i=1;
DT *head,*p;
head=(DT *)malloc(sizeof(DT));
head->num=i++;
head->next=head;
while(i<=n)
{p=(DT *)malloc(sizeof(DT));
p->num=i++;
p->next=head->next;
head->next=p;
}
return (head);
}
main()
{DT *p,*q,*head;
int i=1,j=n,m;
head=create ();
q=head;
while(i<n)
q=q->next;
p=head;
while(p)
{
m=i++;
if(m%3==0)
{
q->next=p->next;
free(p);
j--;
}
p=p->next;
if(j==1) break;
}
printf("%d",p->num);
}
用单链表 编写从八只猴子中选出一个大王 看看哪错啦!