作者在 2012-05-10 22:58:17 发布以下内容
#include<stdio.h>
#include<stdlib.h>
typedef struct N{
int i;
struct N* next;
}List;
int main(void){
List *L,*H,*P,*Q;
L=(List *)malloc(sizeof(List));
L->i=1;
L->next=NULL;
H=L;
P=L;
int j;
int n=0;
int k=0;
for(j=2;j<=30;j++){
Q=(List *)malloc(sizeof(List));
Q->i=j;
Q->next=NULL;
P->next=Q;
P=Q;
}
P->next=H;
k=1;
while(n<15){
H=H->next;
k++;
if(k==8){
printf(" %d ",H->next->i);
H->next=H->next->next;
n++;
k=0;
}
}
return 0;
}
#include<stdlib.h>
typedef struct N{
int i;
struct N* next;
}List;
int main(void){
List *L,*H,*P,*Q;
L=(List *)malloc(sizeof(List));
L->i=1;
L->next=NULL;
H=L;
P=L;
int j;
int n=0;
int k=0;
for(j=2;j<=30;j++){
Q=(List *)malloc(sizeof(List));
Q->i=j;
Q->next=NULL;
P->next=Q;
P=Q;
}
P->next=H;
k=1;
while(n<15){
H=H->next;
k++;
if(k==8){
printf(" %d ",H->next->i);
H->next=H->next->next;
n++;
k=0;
}
}
return 0;
}