⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch23-14(2).c

📁 C语言程序设计上机指导与练习 冶金工业出版社 刘怀亮
💻 C
字号:
#define N 13 
#define LEN sizeof(struct person) 
#include<stdio.h> 
#include<conio.h> 
#include<malloc.h> 
#include<stdlib.h> 
struct person  
{ 
   int number; 
   struct person *next; 
}; 
void main() 
{ 
   int i,count; 
   struct person *head,*p1,*p2; 
   head=p2=NULL; 
   for(i=1;i<=N;i++) 
   { 
      p1=(struct person *)malloc(LEN); 
      p1->number=i; 
      if(head==NULL) head=p1; 
      else p2->next=p1; 
      p2=p1; 
   } 
   p2->next=head; 
   printf("\nThe sequence out of the circle is:\n"); 
   for (count=1;count<N;count++) 
   { 
      i=1; 
      while(i!=3) 
      { 
         p1=head; 
         head=head->next; 
         i++; 
      } 
      p2=head; 
      printf("%3d ",p2->number); 
      p1->next=head=p2->next; 
      free(p2); 
   } 
   printf("\nThe betrayer of them is:\n%3d",head->number); 
   getch(); 
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -