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

📄 吴尚杰 数据结构 原程序.txt

📁 这是一个数据结构八皇后问题的程序
💻 TXT
字号:
//小程序
//2_0
#include"linklist.h"
void Print(link l)
{
   link p;
   p=l;
   while (p!=NULL)
   {
      visite_snode(p,1);
      p=p->next;
   }
}
void reverse(link  &L)
{
   link h,u;
   h=NULL;
   while(L!=NULL)
   {
      u=L;
      L=L->next;
      u->next=h;
      h=u;
   }
   L=h;
}
void main()
{ link l;
  load_hsllist(l);
  comput_sllist_card(l,50,100);
  disp_hsllist("Sllist",l);
  Print(l);
  reverse(l->next);
  comput_sllist_card(l, 50,250);
  disp_hsllist("reverse",l);
  Print(l);
  getch();

  }
//3_3
#include "linklist.h"

void visitelink(link l)
{
	link p;
	int num;
	p=l;
	num=0;
	while (p->next!=l)
	{
		//visite_snode(p,1);
		cout<<p->data<<' ';
		p=p->next;
	}
	cout<<p->data;
	//printf("\n");
}

void main()
{
	link l1;
	int x;
	get_ccsllist(l1);
	display_ccsllist("List",l1);
	visitelink(l1);
       //   x=linklength(l1);
       //   printf("\nLength=%d",x);
	getch();
}
//大程序 八皇后问题
//运行环境TC3.0
#include<math.h>                              //调用数学函数库
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>                      //调用图形函数库
#define MAX 8
int board[MAX];

void Drow()
{
  int i;
  int Driver=VGA,Mode=VGAHI;
      initgraph(&Driver,&Mode,"d:\\tc\\bgi");
      setfillstyle(SOLID_FILL,BLUE);
      bar(5,15,600,500);
      setcolor(YELLOW);
      for(i=0;i<=9;i++)
      {
	 line(10,20+50*i,460,20+50*i);
      }
      for(i=0;i<=9;i++)
      {
	 line(10+50*i,20,10+50*i,470);
      }
      line(460,20,560,20);
      line(10,470,560,470);
      line(560,470,560,20);
      setcolor(RED);
      outtextxy(465,30,"WuShangjie");
      outtextxy(465,45,"Eight Queue");
      outtextxy(465,60,"CopyRight2.0");

      outtextxy(415,440,"Start");
       outtextxy(385,440,"0");
       outtextxy(335,440,"1");
       outtextxy(285,440,"2");
       outtextxy(235,440,"3");
       outtextxy(185,440,"4");
       outtextxy(135,440,"5");
       outtextxy(85,440,"6");
       outtextxy(35,440,"7");

     outtextxy(415,455,"Point");
       outtextxy(435,390,"0");
       outtextxy(435,340,"1");
       outtextxy(435,290,"2");
       outtextxy(435,240,"3");
       outtextxy(435,190,"4");
       outtextxy(435,140,"5");
       outtextxy(435,90,"6");
       outtextxy(435,40,"7");
}
void DrowCircle(int i,int j)
{
  char text[80];
  setfillstyle(SOLID_FILL,YELLOW);
  setcolor(YELLOW);
  circle(385-50*i,395-50*j,15);
  floodfill(385-50*i,395-50*j,YELLOW);
  setcolor(RED);
  sprintf(text,"%d,%d",i,j);
  outtextxy(385-50*i-14,395-50*j,text);
}
void GiveDrowIn(int i,int j)
{
  setfillstyle(SOLID_FILL,BLUE);
  setcolor(BLUE);
  circle(385-50*i,395-50*j,15);
  floodfill(385-50*i,395-50*j,BLUE);
  outtextxy(385-50*i-14,395-50*j,"                   ");
}

void show_result()
{
     int j=0;
     while(j<MAX)
       {
	DrowCircle(j,board[j]);
	getch();
	j++;
       }
	getch();
     for(j=0;j<MAX;j++)
       {
	GiveDrowIn(j,board[j]);
       }
	getch();
}
int check_cross(int n)
{
    int k;
    for(k=0;k<n;k++){
       if(board[k]==board[n]||(n-k)==abs(board[k]-board[n]))
       return 1;
       }
       return 0;
}
void put_chess(int n)
{
     for(int l=0;l<MAX;l++){
	     board[n]=l;
	 if(!check_cross(n)){
	  if(n==MAX-1) {
			 getch();
			 show_result();
			}
	  else put_chess(n+1);
	 }
     }
}
void main()
{

  Drow();
  put_chess(0);

//to the end of the program
  getch();
  exit(1);
}

⌨️ 快捷键说明

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