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

📄 约瑟夫环2.txt

📁 数据结构学习用到的一些程序!!里面有二叉树相关的几个
💻 TXT
字号:
#include<malloc.h>
#include<stdio.h> 
#define LEN sizeof(struct shu) 
#define NULL 0 
struct shu 
{int num; 
 struct shu *next; 
 }; 
 main() 
 {struct shu *p,*q,*head; 
 int i,a,b; 
 head=NULL; 
 p=q=(struct shu *)malloc(LEN); 
 scanf("%d",&p->num); 
 while(p->num!=NULL) 
 {if(head==NULL)head=p; 
 else {q->next=p;q=p;} 
 p=(struct shu *)malloc(LEN); 
 scanf("%d",&p->num); 
 } 
 q->next=head; 
 scanf("\n%d%d\n",&a,&b); 
 while(q->num!=a) 
 q=q->next; 
 p=q->next; 
 while(p!=q) 
 {for(i=1;i<=b-2;i++) 
 {q=p;p=p->next;} 
 q->next=p->next; 
 printf("%d",p->num); 
 q=q->next; 
 p=q->next; 
 } 
 printf("%d",q->num); 
}

⌨️ 快捷键说明

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