Placer 8 reines sur un echiquier (technique matricielle) et (affichage dans un bo form)

Soyez le premier à donner votre avis sur cette source.

Snippet vu 11 410 fois - Téléchargée 33 fois

Contenu du snippet

j'ai eu envi de refaire un second programme cherchant a positionner les 8 dames. celui ci présente beaucoup - d'interet o niveau programmation, mais nous donne un résultat beaucoup + agréable o régard.

Source / Exemple :


using System;
using System.IO;
using System.Windows.Forms;
using System.Drawing;
namespace MyForm {
public class CreatedForm : System.Windows.Forms.Form {
//on créé un form contenant les 64 'Panel' représentant les 64 cases du jeux d'echec nommée de a1 à h8, un 'button' pour démarrer le prog et un 'label' servant de compteur pour les solutions.
	private System.Windows.Forms.Panel h8;private System.Windows.Forms.Panel d1;private System.Windows.Forms.Panel d3;private System.Windows.Forms.Panel d2;private System.Windows.Forms.Panel d5;private System.Windows.Forms.Panel d4;private System.Windows.Forms.Panel d7;private System.Windows.Forms.Panel d6;private System.Windows.Forms.Panel d8;private System.Windows.Forms.Panel e1;private System.Windows.Forms.Panel e2;private System.Windows.Forms.Panel e3;private System.Windows.Forms.Panel e4;private System.Windows.Forms.Panel e5;private System.Windows.Forms.Panel e6;private System.Windows.Forms.Panel e7;private System.Windows.Forms.Panel e8;private System.Windows.Forms.Panel f3;private System.Windows.Forms.Panel f2;private System.Windows.Forms.Panel f7;private System.Windows.Forms.Panel f6;private System.Windows.Forms.Panel f5;private System.Windows.Forms.Panel f4;private System.Windows.Forms.Panel f8;
	private System.Windows.Forms.Panel g2;private System.Windows.Forms.Panel g3;private System.Windows.Forms.Panel g1;private System.Windows.Forms.Panel g6;private System.Windows.Forms.Panel g7;private System.Windows.Forms.Panel g4;private System.Windows.Forms.Panel g5;private System.Windows.Forms.Panel g8;private System.Windows.Forms.Button button;private System.Windows.Forms.Panel a4;private System.Windows.Forms.Panel a5;private System.Windows.Forms.Panel a6;private System.Windows.Forms.Panel a7;private System.Windows.Forms.Panel a1;private System.Windows.Forms.Panel a2;private System.Windows.Forms.Panel a3;private System.Windows.Forms.TextBox textBox2;private System.Windows.Forms.Panel a8;private System.Windows.Forms.Panel b7;private System.Windows.Forms.Panel b6;private System.Windows.Forms.Panel b5;private System.Windows.Forms.Panel b4;private System.Windows.Forms.Panel b3;private System.Windows.Forms.Panel b2;
	private System.Windows.Forms.Panel b1;private System.Windows.Forms.Panel b8;private System.Windows.Forms.Panel c6;private System.Windows.Forms.Panel c7;private System.Windows.Forms.Panel c4;private System.Windows.Forms.Panel c5;private System.Windows.Forms.Panel c2;private System.Windows.Forms.Panel c3;private System.Windows.Forms.Panel c1;private System.Windows.Forms.Panel c8;private System.Windows.Forms.Panel f1;private System.Windows.Forms.GroupBox groupBox;private System.Windows.Forms.Panel h5;private System.Windows.Forms.Panel h4;private System.Windows.Forms.Panel h7;private System.Windows.Forms.Panel h6;private System.Windows.Forms.Panel h1;private System.Windows.Forms.Panel h3;private System.Windows.Forms.Panel h2;private System.Windows.Forms.TextBox textBox;
	int[,] tab = new int [40,40];	int compteur; //je crée un tableau en int de 40 sur 40
public CreatedForm(){
	InitializeComponent();
	}
void InitializeComponent() {
	this.textBox = new System.Windows.Forms.TextBox();
	this.h2 = new System.Windows.Forms.Panel();this.h3 = new System.Windows.Forms.Panel();this.h1 = new System.Windows.Forms.Panel();this.h6 = new System.Windows.Forms.Panel();this.h7 = new System.Windows.Forms.Panel();this.h4 = new System.Windows.Forms.Panel();this.h5 = new System.Windows.Forms.Panel();this.groupBox = new System.Windows.Forms.GroupBox();this.f1 = new System.Windows.Forms.Panel();this.c8 = new System.Windows.Forms.Panel();this.c1 = new System.Windows.Forms.Panel();this.c3 = new System.Windows.Forms.Panel();this.c2 = new System.Windows.Forms.Panel();this.c5 = new System.Windows.Forms.Panel();this.c4 = new System.Windows.Forms.Panel();this.c7 = new System.Windows.Forms.Panel();this.c6 = new System.Windows.Forms.Panel();this.b8 = new System.Windows.Forms.Panel();this.b1 = new System.Windows.Forms.Panel();
	this.b2 = new System.Windows.Forms.Panel();this.b3 = new System.Windows.Forms.Panel();this.b4 = new System.Windows.Forms.Panel();this.b5 = new System.Windows.Forms.Panel();this.b6 = new System.Windows.Forms.Panel();this.b7 = new System.Windows.Forms.Panel();this.a8 = new System.Windows.Forms.Panel();this.textBox2 = new System.Windows.Forms.TextBox();this.a3 = new System.Windows.Forms.Panel();this.a2 = new System.Windows.Forms.Panel();this.a1 = new System.Windows.Forms.Panel();this.a7 = new System.Windows.Forms.Panel();this.a6 = new System.Windows.Forms.Panel();this.a5 = new System.Windows.Forms.Panel();this.a4 = new System.Windows.Forms.Panel();this.button = new System.Windows.Forms.Button();this.g8 = new System.Windows.Forms.Panel();this.g5 = new System.Windows.Forms.Panel();this.g4 = new System.Windows.Forms.Panel();this.g7 = new System.Windows.Forms.Panel();
	this.g6 = new System.Windows.Forms.Panel();this.g1 = new System.Windows.Forms.Panel();this.g3 = new System.Windows.Forms.Panel();this.g2 = new System.Windows.Forms.Panel();this.f8 = new System.Windows.Forms.Panel();this.f4 = new System.Windows.Forms.Panel();this.f5 = new System.Windows.Forms.Panel();this.f6 = new System.Windows.Forms.Panel();this.f7 = new System.Windows.Forms.Panel();this.f2 = new System.Windows.Forms.Panel();this.f3 = new System.Windows.Forms.Panel();this.e8 = new System.Windows.Forms.Panel();this.e7 = new System.Windows.Forms.Panel();this.e6 = new System.Windows.Forms.Panel();this.e5 = new System.Windows.Forms.Panel();this.e4 = new System.Windows.Forms.Panel();this.e3 = new System.Windows.Forms.Panel();this.e2 = new System.Windows.Forms.Panel();this.e1 = new System.Windows.Forms.Panel();this.d8 = new System.Windows.Forms.Panel();
	this.d6 = new System.Windows.Forms.Panel();this.d7 = new System.Windows.Forms.Panel();this.d4 = new System.Windows.Forms.Panel();this.d5 = new System.Windows.Forms.Panel();this.d2 = new System.Windows.Forms.Panel();this.d3 = new System.Windows.Forms.Panel();this.d1 = new System.Windows.Forms.Panel();this.h8 = new System.Windows.Forms.Panel();this.SuspendLayout();
	this.groupBox.SuspendLayout();

// groupBox
this.groupBox.Controls.AddRange(new System.Windows.Forms.Control[] {this.h1,this.g1,this.f1,this.e1,this.d1,this.c1,this.b1,this.a1,this.h2,this.g2,this.f2,this.e2,this.d2,this.c2,this.b2,this.a2,this.h3,this.g3,this.f3,this.e3,this.d3,this.c3,this.b3,this.a3,this.h4,this.g4,this.f4,this.e4,this.d4,this.c4,this.b4,this.a4,this.h5,this.g5,this.f5,this.e5,this.d5,this.c5,this.b5,this.a5,this.h6,this.g6,this.f6,this.e6,this.d6,this.c6,this.b6,this.a6,this.h7,this.g7,this.f7,this.e7,this.d7,this.c7,this.b7,this.a7,this.h8,this.g8,this.f8,this.e8,this.d8,this.c8,this.b8,this.a8});this.groupBox.Location = new System.Drawing.Point(8, 8);this.groupBox.Name = "groupBox";this.groupBox.Size = new System.Drawing.Size(264, 272);this.groupBox.TabIndex = 0;this.groupBox.TabStop = false;this.groupBox.Text = "Jeu d'echec";
// h1
this.h1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h1.Location = new System.Drawing.Point(232, 240);this.h1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.h1.Name = "h1";this.h1.Size = new System.Drawing.Size(24, 24);this.h1.TabIndex = 0;
// h2
this.h2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h2.Location = new System.Drawing.Point(232, 208);this.h2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.h2.Name = "h2";this.h2.Size = new System.Drawing.Size(24, 24);this.h2.TabIndex = 0;
// h3
this.h3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h3.Location = new System.Drawing.Point(232, 176);this.h3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.h3.Name = "h3";this.h3.Size = new System.Drawing.Size(24, 24);this.h3.TabIndex = 0;
// h4
this.h4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h4.Location = new System.Drawing.Point(232, 144);this.h4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.h4.Name = "h4";this.h4.Size = new System.Drawing.Size(24, 24);this.h4.TabIndex = 0;
// h5
this.h5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h5.Location = new System.Drawing.Point(232, 112);this.h5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.h5.Name = "h5";this.h5.Size = new System.Drawing.Size(24, 24);this.h5.TabIndex = 0;
// h6
this.h6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h6.Location = new System.Drawing.Point(232, 80);this.h6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.h6.Name = "h6";this.h6.Size = new System.Drawing.Size(24, 24);this.h6.TabIndex = 0;
// h7
this.h7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h7.Location = new System.Drawing.Point(232, 48);this.h7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.h7.Name = "h7";this.h7.Size = new System.Drawing.Size(24, 24);this.h7.TabIndex = 0;
// f1
this.f1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f1.Location = new System.Drawing.Point(168, 240);this.f1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.f1.Name = "panel3";this.f1.Size = new System.Drawing.Size(24, 24);this.f1.TabIndex = 0;
// c8
this.c8.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c8.Location = new System.Drawing.Point(72, 16);this.c8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.c8.Name = "c8";this.c8.Size = new System.Drawing.Size(24, 24);this.c8.TabIndex = 0;
// c1
this.c1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c1.Location = new System.Drawing.Point(72, 240);this.c1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.c1.Name = "c1";this.c1.Size = new System.Drawing.Size(24, 24);this.c1.TabIndex = 0;
// c3
this.c3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c3.Location = new System.Drawing.Point(72, 176);this.c3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.c3.Name = "c3";this.c3.Size = new System.Drawing.Size(24, 24);this.c3.TabIndex = 0;
// c2
this.c2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c2.Location = new System.Drawing.Point(72, 208);this.c2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.c2.Name = "c2";this.c2.Size = new System.Drawing.Size(24, 24);this.c2.TabIndex = 0;
// c5
this.c5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c5.Location = new System.Drawing.Point(72, 112);this.c5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.c5.Name = "c5";this.c5.Size = new System.Drawing.Size(24, 24);this.c5.TabIndex = 0;
// c4
this.c4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c4.Location = new System.Drawing.Point(72, 144);this.c4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.c4.Name = "c4";this.c4.Size = new System.Drawing.Size(24, 24);this.c4.TabIndex = 0;
// c7
this.c7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c7.Location = new System.Drawing.Point(72, 48);this.c7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.c7.Name = "c7";this.c7.Size = new System.Drawing.Size(24, 24);this.c7.TabIndex = 0;
// c6
this.c6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c6.Location = new System.Drawing.Point(72, 80);this.c6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.c6.Name = "c6";this.c6.Size = new System.Drawing.Size(24, 24);this.c6.TabIndex = 0;
// b8
this.b8.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b8.Location = new System.Drawing.Point(40, 16);this.b8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.b8.Name = "b8";this.b8.Size = new System.Drawing.Size(24, 24);this.b8.TabIndex = 0;
// b1
this.b1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b1.Location = new System.Drawing.Point(40, 240);this.b1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.b1.Name = "b1";this.b1.Size = new System.Drawing.Size(24, 24);this.b1.TabIndex = 0;
// b2
this.b2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b2.Location = new System.Drawing.Point(40, 208);this.b2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.b2.Name = "b2";this.b2.Size = new System.Drawing.Size(24, 24);this.b2.TabIndex = 0;
// b3
this.b3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b3.Location = new System.Drawing.Point(40, 176);this.b3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.b3.Name = "b3";this.b3.Size = new System.Drawing.Size(24, 24);this.b3.TabIndex = 0;
// b4
this.b4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b4.Location = new System.Drawing.Point(40, 144);this.b4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.b4.Name = "b4";this.b4.Size = new System.Drawing.Size(24, 24);this.b4.TabIndex = 0;
// b5
this.b5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b5.Location = new System.Drawing.Point(40, 112);this.b5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.b5.Name = "b5";this.b5.Size = new System.Drawing.Size(24, 24);this.b5.TabIndex = 0;
// b6
this.b6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b6.Location = new System.Drawing.Point(40, 80);this.b6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.b6.Name = "b6";this.b6.Size = new System.Drawing.Size(24, 24);this.b6.TabIndex = 0;
// b7
this.b7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b7.Location = new System.Drawing.Point(40, 48);this.b7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.b7.Name = "b7";this.b7.Size = new System.Drawing.Size(24, 24);this.b7.TabIndex = 0;
// a8 
this.a8.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a8.Location = new System.Drawing.Point(8, 16);this.a8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.a8.Name = "a8";this.a8.Size = new System.Drawing.Size(24, 24);this.a8.TabIndex = 0;
// a3
this.a3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a3.Location = new System.Drawing.Point(8, 176);this.a3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.a3.Name = "a3";this.a3.Size = new System.Drawing.Size(24, 24);this.a3.TabIndex = 0;
// a2
this.a2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a2.Location = new System.Drawing.Point(8, 208);this.a2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.a2.Name = "a2";this.a2.Size = new System.Drawing.Size(24, 24);this.a2.TabIndex = 0;
// a1
this.a1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a1.Location = new System.Drawing.Point(8, 240);this.a1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.a1.Name = "a1";this.a1.Size = new System.Drawing.Size(24, 24);this.a1.TabIndex = 0;
// a7
this.a7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a7.Location = new System.Drawing.Point(8, 48);this.a7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.a7.Name = "a7";this.a7.Size = new System.Drawing.Size(24, 24);this.a7.TabIndex = 0;
// a6
this.a6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a6.Location = new System.Drawing.Point(8, 80);this.a6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.a6.Name = "a6";this.a6.Size = new System.Drawing.Size(24, 24);this.a6.TabIndex = 0;
// a5
this.a5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a5.Location = new System.Drawing.Point(8, 112);this.a5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.a5.Name = "a5";this.a5.Size = new System.Drawing.Size(24, 24);this.a5.TabIndex = 0;
// a4
this.a4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a4.Location = new System.Drawing.Point(8, 144);this.a4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.a4.Name = "a4";this.a4.Size = new System.Drawing.Size(24, 24);this.a4.TabIndex = 0;
// button
this.button.Location = new System.Drawing.Point(8, 288);this.button.Name = "button";this.button.TabIndex = 0;this.button.Text = "Solutions";this.button.Click += new System.EventHandler(this.D1);
// g8
this.g8.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g8.Location = new System.Drawing.Point(200, 16);this.g8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.g8.Name = "g8";this.g8.Size = new System.Drawing.Size(24, 24);this.g8.TabIndex = 0;
// g5
this.g5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g5.Location = new System.Drawing.Point(200, 112);this.g5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.g5.Name = "g5";this.g5.Size = new System.Drawing.Size(24, 24);this.g5.TabIndex = 0;
// g4
this.g4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g4.Location = new System.Drawing.Point(200, 144);this.g4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.g4.Name = "g4";this.g4.Size = new System.Drawing.Size(24, 24);this.g4.TabIndex = 0;
// g7
this.g7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g7.Location = new System.Drawing.Point(200, 48);this.g7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.g7.Name = "g7";this.g7.Size = new System.Drawing.Size(24, 24);this.g7.TabIndex = 0;
// g6
this.g6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g6.Location = new System.Drawing.Point(200, 80);this.g6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.g6.Name = "g6";this.g6.Size = new System.Drawing.Size(24, 24);this.g6.TabIndex = 0;
// g1
this.g1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g1.Location = new System.Drawing.Point(200, 240);this.g1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.g1.Name = "g1";this.g1.Size = new System.Drawing.Size(24, 24);this.g1.TabIndex = 0;
// g3
this.g3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g3.Location = new System.Drawing.Point(200, 176);this.g3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.g3.Name = "g3";this.g3.Size = new System.Drawing.Size(24, 24);this.g3.TabIndex = 0;
// g2
this.g2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g2.Location = new System.Drawing.Point(200, 208);this.g2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.g2.Name = "g2";this.g2.Size = new System.Drawing.Size(24, 24);this.g2.TabIndex = 0;
// f8
this.f8.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f8.Location = new System.Drawing.Point(168, 16);this.f8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.f8.Name = "f8";this.f8.Size = new System.Drawing.Size(24, 24);this.f8.TabIndex = 0;
// f4
this.f4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f4.Location = new System.Drawing.Point(168, 144);this.f4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.f4.Name = "f4";this.f4.Size = new System.Drawing.Size(24, 24);this.f4.TabIndex = 0;
// f5
this.f5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f5.Location = new System.Drawing.Point(168, 112);this.f5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.f5.Name = "f5";this.f5.Size = new System.Drawing.Size(24, 24);this.f5.TabIndex = 0;
// f6
this.f6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f6.Location = new System.Drawing.Point(168, 80);this.f6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.f6.Name = "f6";this.f6.Size = new System.Drawing.Size(24, 24);this.f6.TabIndex = 0;
// f7
this.f7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f7.Location = new System.Drawing.Point(168, 48);this.f7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.f7.Name = "f7";this.f7.Size = new System.Drawing.Size(24, 24);this.f7.TabIndex = 0;
// f2
this.f2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f2.Location = new System.Drawing.Point(168, 208);this.f2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.f2.Name = "f2";this.f2.Size = new System.Drawing.Size(24, 24);this.f2.TabIndex = 0;
// f3
this.f3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f3.Location = new System.Drawing.Point(168, 176);this.f3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.f3.Name = "f3";this.f3.Size = new System.Drawing.Size(24, 24);this.f3.TabIndex = 0;
// e8
this.e8.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e8.Location = new System.Drawing.Point(136, 16);this.e8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.e8.Name = "e8";this.e8.Size = new System.Drawing.Size(24, 24);this.e8.TabIndex = 0;
// e7
this.e7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e7.Location = new System.Drawing.Point(136, 48);this.e7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.e7.Name = "e7";this.e7.Size = new System.Drawing.Size(24, 24);this.e7.TabIndex = 0;
// e6
this.e6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e6.Location = new System.Drawing.Point(136, 80);this.e6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.e6.Name = "e6";this.e6.Size = new System.Drawing.Size(24, 24);this.e6.TabIndex = 0;
// e5
this.e5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e5.Location = new System.Drawing.Point(136, 112);this.e5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.e5.Name = "e5";this.e5.Size = new System.Drawing.Size(24, 24);this.e5.TabIndex = 0;
// e4
this.e4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e4.Location = new System.Drawing.Point(136, 144);this.e4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.e4.Name = "e4";this.e4.Size = new System.Drawing.Size(24, 24);this.e4.TabIndex = 0;
// e3
this.e3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.e3.Location = new System.Drawing.Point(136, 176);this.e3.Name = "e3";this.e3.Size = new System.Drawing.Size(24, 24);this.e3.TabIndex = 0;
// e2
this.e2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.e2.Location = new System.Drawing.Point(136, 208);this.e2.Name = "e2";this.e2.Size = new System.Drawing.Size(24, 24);this.e2.TabIndex = 0;
// e1
this.e1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e1.Location = new System.Drawing.Point(136, 240);this.e1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.e1.Name = "e1";this.e1.Size = new System.Drawing.Size(24, 24);this.e1.TabIndex = 0;
// d8
this.d8.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d8.Location = new System.Drawing.Point(104, 16);this.d8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.d8.Name = "d8";this.d8.Size = new System.Drawing.Size(24, 24);this.d8.TabIndex = 0;
// d6
this.d6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d6.Location = new System.Drawing.Point(104, 80);this.d6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.d6.Name = "d6";this.d6.Size = new System.Drawing.Size(24, 24);this.d6.TabIndex = 0;
// d7
this.d7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d7.Location = new System.Drawing.Point(104, 48);this.d7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.d7.Name = "d7";this.d7.Size = new System.Drawing.Size(24, 24);this.d7.TabIndex = 0;
// d4
this.d4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d4.Location = new System.Drawing.Point(104, 144);this.d4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.d4.Name = "d4";this.d4.Size = new System.Drawing.Size(24, 24);this.d4.TabIndex = 0;
// d5
this.d5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d5.Location = new System.Drawing.Point(104, 112);this.d5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.d5.Name = "d5";this.d5.Size = new System.Drawing.Size(24, 24);this.d5.TabIndex = 0;
// d2
this.d2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.d2.Location = new System.Drawing.Point(104, 208);this.d2.Name = "d2";this.d2.Size = new System.Drawing.Size(24, 24);this.d2.TabIndex = 0;
// d3
this.d3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.d3.Location = new System.Drawing.Point(104, 176);this.d3.Name = "d3";this.d3.Size = new System.Drawing.Size(24, 24);this.d3.TabIndex = 0;
// d1
this.d1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.d1.Location = new System.Drawing.Point(104, 240);this.d1.Name = "d1";this.d1.Size = new System.Drawing.Size(24, 24);this.d1.TabIndex = 0;
// h8
this.h8.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;this.h8.Location = new System.Drawing.Point(232, 16);this.h8.Name = "h8";this.h8.Size = new System.Drawing.Size(24, 24);this.h8.TabIndex = 0;
// CreatedForm
this.ClientSize = new System.Drawing.Size(280, 320);this.Controls.AddRange(new System.Windows.Forms.Control[] {this.button,this.groupBox});
this.groupBox.ResumeLayout(false);
this.ResumeLayout(false);
}
public static void Main()
	{
	Application.Run(new CreatedForm());

	}
public void D1(object ob,System.EventArgs ev)
     {
this.a1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.a8.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.b1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.b8.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.c1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.c8.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.d1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.d8.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.e1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.e8.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.f1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.f8.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.g1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.g8.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.h1.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h2.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h3.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h4.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h5.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h6.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h7.BackColor = System.Drawing.SystemColors.ControlLightLight;this.h8.BackColor = System.Drawing.SystemColors.ControlLightLight;
int ok=0,x=21,y=21,w =0;
if(tab[28,1] != 0)
{
x = 28;
y = tab[x,1];
tab[x,y]= 0;
tab[x,1]= 0;
w=1;
while(w != 8){tab[x+w,y]--;tab[x-w,y]--;tab[x,y+w]--;tab[x,y-w]--;tab[x+w,y+w]--;tab[x-w,y+w]--;tab[x+w,y-w]--;tab[x-w,y-w]--;w++;}
y++;
}
while(ok != 1)
{
while(y != 29 )
{
        if(tab[x,y] == 0)
        {
        tab[x,y] = 20;
        w=1;
       	while(w != 8){tab[x+w,y]++;tab[x-w,y]++;tab[x,y+w]++;tab[x,y-w]++;tab[x+w,y+w]++;tab[x-w,y+w]++;tab[x+w,y-w]++;tab[x-w,y-w]++;w++;}
    	tab[x,1]= y;
        y = 21;
        x++;
        if(x == 29)
        {
        ok=1;
        y=29;
        }
        }
   else
{
y++;
}
}
if(ok != 1)
{
if(y == 29)
{
x--;
if(x != 20)
{
y  = tab[x,1];
tab[x,y] = 0;
w=1;
while(w != 8){tab[x+w,y]--;tab[x-w,y]--;tab[x,y+w]--;tab[x,y-w]--;tab[x+w,y+w]--;tab[x-w,y+w]--;tab[x+w,y-w]--;tab[x-w,y-w]--;w++;}
tab[x,1]= 0;
y++;
}
else
{
ok=1;
}
}
}
}
if(ok == 1)
compteur ++;
Console.Out.WriteLine("solution = "+compteur);
     	if(compteur == 92){
     		compteur=0;
     		MessageBox.Show("Le programme a trouvé toutes les solutions soit : 92","alerte", MessageBoxButtons.OK);
     	}
{
this.button.Text = "Suite =>";
// on met de l'or dans les cases contenant des reines

w = tab[21,21];if(w > 15){this.a1.BackColor = System.Drawing.Color.Gold;}w = tab[21,22];if(w > 15){this.a2.BackColor = System.Drawing.Color.Gold;}w = tab[21,23];if(w > 15){this.a3.BackColor = System.Drawing.Color.Gold;}w = tab[21,24];if(w > 15){this.a4.BackColor = System.Drawing.Color.Gold;}w = tab[21,25];if(w > 15){this.a5.BackColor = System.Drawing.Color.Gold;}w = tab[21,26];if(w > 15){this.a6.BackColor = System.Drawing.Color.Gold;}w = tab[21,27];if(w > 15){this.a7.BackColor = System.Drawing.Color.Gold;}w = tab[21,28];if(w > 15){this.a8.BackColor = System.Drawing.Color.Gold;}
w = tab[22,21];if(w > 15){this.b1.BackColor = System.Drawing.Color.Gold;}w = tab[22,22];if(w > 15){this.b2.BackColor = System.Drawing.Color.Gold;}w = tab[22,23];if(w > 15){this.b3.BackColor = System.Drawing.Color.Gold;}w = tab[22,24];if(w > 15){this.b4.BackColor = System.Drawing.Color.Gold;}w = tab[22,25];if(w > 15){this.b5.BackColor = System.Drawing.Color.Gold;}w = tab[22,26];if(w > 15){this.b6.BackColor = System.Drawing.Color.Gold;}w = tab[22,27];if(w > 15){this.b7.BackColor = System.Drawing.Color.Gold;}w = tab[22,28];if(w > 15){this.b8.BackColor = System.Drawing.Color.Gold;}
w = tab[23,21];if(w > 15){this.c1.BackColor = System.Drawing.Color.Gold;}w = tab[23,22];if(w > 15){this.c2.BackColor = System.Drawing.Color.Gold;}w = tab[23,23];if(w > 15){this.c3.BackColor = System.Drawing.Color.Gold;}w = tab[23,24];if(w > 15){this.c4.BackColor = System.Drawing.Color.Gold;}w = tab[23,25];if(w > 15){this.c5.BackColor = System.Drawing.Color.Gold;}w = tab[23,26];if(w > 15){this.c6.BackColor = System.Drawing.Color.Gold;}w = tab[23,27];if(w > 15){this.c7.BackColor = System.Drawing.Color.Gold;}w = tab[23,28];if(w > 15){this.c8.BackColor = System.Drawing.Color.Gold;}
w = tab[24,21];if(w > 15){this.d1.BackColor = System.Drawing.Color.Gold;}w = tab[24,22];if(w > 15){this.d2.BackColor = System.Drawing.Color.Gold;}w = tab[24,23];if(w > 15){this.d3.BackColor = System.Drawing.Color.Gold;}w = tab[24,24];if(w > 15){this.d4.BackColor = System.Drawing.Color.Gold;}w = tab[24,25];if(w > 15){this.d5.BackColor = System.Drawing.Color.Gold;}w = tab[24,26];if(w > 15){this.d6.BackColor = System.Drawing.Color.Gold;}w = tab[24,27];if(w > 15){this.d7.BackColor = System.Drawing.Color.Gold;}w = tab[24,28];if(w > 15){this.d8.BackColor = System.Drawing.Color.Gold;}
w = tab[25,21];if(w > 15){this.e1.BackColor = System.Drawing.Color.Gold;}w = tab[25,22];if(w > 15){this.e2.BackColor = System.Drawing.Color.Gold;}w = tab[25,23];if(w > 15){this.e3.BackColor = System.Drawing.Color.Gold;}w = tab[25,24];if(w > 15){this.e4.BackColor = System.Drawing.Color.Gold;}w = tab[25,25];if(w > 15){this.e5.BackColor = System.Drawing.Color.Gold;}w = tab[25,26];if(w > 15){this.e6.BackColor = System.Drawing.Color.Gold;}w = tab[25,27];if(w > 15){this.e7.BackColor = System.Drawing.Color.Gold;}w = tab[25,28];if(w > 15){this.e8.BackColor = System.Drawing.Color.Gold;}
w = tab[26,21];if(w > 15){this.f1.BackColor = System.Drawing.Color.Gold;}w = tab[26,22];if(w > 15){this.f2.BackColor = System.Drawing.Color.Gold;}w = tab[26,23];if(w > 15){this.f3.BackColor = System.Drawing.Color.Gold;}w = tab[26,24];if(w > 15){this.f4.BackColor = System.Drawing.Color.Gold;}w = tab[26,25];if(w > 15){this.f5.BackColor = System.Drawing.Color.Gold;}w = tab[26,26];if(w > 15){this.f6.BackColor = System.Drawing.Color.Gold;}w = tab[26,27];if(w > 15){this.f7.BackColor = System.Drawing.Color.Gold;}w = tab[26,28];if(w > 15){this.f8.BackColor = System.Drawing.Color.Gold;}
w = tab[27,21];if(w > 15){this.g1.BackColor = System.Drawing.Color.Gold;}w = tab[27,22];if(w > 15){this.g2.BackColor = System.Drawing.Color.Gold;}w = tab[27,23];if(w > 15){this.g3.BackColor = System.Drawing.Color.Gold;}w = tab[27,24];if(w > 15){this.g4.BackColor = System.Drawing.Color.Gold;}w = tab[27,25];if(w > 15){this.g5.BackColor = System.Drawing.Color.Gold;}w = tab[27,26];if(w > 15){this.g6.BackColor = System.Drawing.Color.Gold;}w = tab[27,27];if(w > 15){this.g7.BackColor = System.Drawing.Color.Gold;}w = tab[27,28];if(w > 15){this.g8.BackColor = System.Drawing.Color.Gold;}
w = tab[28,21];if(w > 15){this.h1.BackColor = System.Drawing.Color.Gold;}w = tab[28,22];if(w > 15){this.h2.BackColor = System.Drawing.Color.Gold;}w = tab[28,23];if(w > 15){this.h3.BackColor = System.Drawing.Color.Gold;}w = tab[28,24];if(w > 15){this.h4.BackColor = System.Drawing.Color.Gold;}w = tab[28,25];if(w > 15){this.h5.BackColor = System.Drawing.Color.Gold;}w = tab[28,26];if(w > 15){this.h6.BackColor = System.Drawing.Color.Gold;}w = tab[28,27];if(w > 15){this.h7.BackColor = System.Drawing.Color.Gold;}w = tab[28,28];if(w > 15){this.h8.BackColor = System.Drawing.Color.Gold;}
}
}
}
}

Conclusion :


ce programme commence par poser une reine dans la première case, il en pose une seconde dans la première possible sur la sonconde ligne.
des que ce nes plus possible il retire une reine puis continu.

A voir également

Ajouter un commentaire

Commentaire

gg00xiv
Messages postés
656
Date d'inscription
mercredi 22 août 2001
Statut
Membre
Dernière intervention
11 mars 2005
11 -
Pourquoi ta pas mis le code sur une seule ligne, je pense que cela aurait ete plus clair ...

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.