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

📄 hulichitu.cpp

📁 用C语言编写的狐狸吃兔的实现程序
💻 CPP
字号:
#include <stdio.h>
#include <stdlib.h>
#define OK 1
#define MAX 1000
#define LIST_INIT_SIZE 10
typedef int datatype ;
typedef struct node
{
	int score;
	datatype num;
	struct node *next;
}linklist;

linklist *CREATLISIF()
{
	linklist *head,*s,*tail; int i=LIST_INIT_SIZE;
	head = NULL,tail=NULL;
	while(i>=1)
	{
		s=(linklist*)malloc(sizeof(linklist));		
		s->score=1;
		s->num=i;		
		s->next=head;
		if(i==LIST_INIT_SIZE) tail=s;		
		head=s;
		i--;
	}
	tail->next=head;
	return head;
}
int RABBIT(linklist *L)
{
	linklist *p;
	int i,j;
	p=L;
	for(i=1;i<=MAX;i++)
	{
		p->score=0;
		printf("\nthe No.%d hole ",p->num);
		for(j=1;j<i+2;j++)
		{
			p=p->next;
		}
		
	}
	printf("the rabbit maybe in these holes:\n");
	i=p->num;
	do
	{
		if( p->score==1)
			printf("\nmaybe in the No.%d hole ",p->num);
		p=p->next;
	}while(p->num!=i);
	return OK;
}
void main()
{
	linklist *L;
	L=CREATLISIF();
	RABBIT(L);
}

⌨️ 快捷键说明

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