Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace AplicatiiLee
- {
- public partial class Form1 : Form
- {
- Graphics g;
- Label[,] Lsolutii = new Label[21, 21];
- int[,] solutii = new int[21, 21];
- public static int dimensiunematrice = 51;
- int[,] Harta = new int[dimensiunematrice, dimensiunematrice];
- int[,] Harta01 = new int[21, 21];
- int[,] Harta_originala = new int[dimensiunematrice, dimensiunematrice];
- int nrsolutii = 0, xmousevechi = 0, ymousevechi = 0, deseneaza = 0, numarregiuni = 0;
- public TextBox[] culoriharta = new TextBox[100];
- public Form1()
- {
- InitializeComponent();
- g = pictureBox1.CreateGraphics();
- }
- private void Form1_Click(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int i, j, l;
- string s="";
- for (i = 0; i < dimensiunematrice; i++)
- for (j = 0; j < dimensiunematrice; j++)
- if(Harta[i,j]==0)
- {
- s = "";
- numarregiuni++;
- //MessageBox.Show(numarregiuni.ToString());
- FILL(i, j, numarregiuni);
- /*for (int ii = 0; ii < dimensiunematrice; ii++)
- {
- for (int jj = 0; jj < dimensiunematrice; jj++)
- s = s + Harta[ii, jj] + " ";
- s = s + "\n";
- }
- MessageBox.Show(s);*/
- }
- for (i = 0; i < numarregiuni; i++)
- for (j = 0; j < numarregiuni; j++)
- Harta01[i, j] = 0;
- for (i = 0; i < 50; i++)
- for (j = 0; j < 50; j++)
- {
- if (Harta[i, j] > 0)
- {
- //dreapta
- for (l = i + 1; l < 50; l++)
- if (Harta[l, j] == -1)
- break;
- for (; l < 50; l++)
- if (Harta[l, j] != -1 && Harta[l, j] != Harta[i, j])
- {
- Harta01[Harta[i, j], Harta[l, j]] = 1;
- break;
- }
- //stanga
- for (l = i - 1; l >= 0; l--)
- if (Harta[l, j] == -1)
- break;
- for (; l >= 0; l--)
- if (Harta[l, j] != -1 && Harta[l, j] != Harta[i, j])
- {
- Harta01[Harta[i, j], Harta[l, j]] = 1;
- break;
- }
- //jos
- for (l = j + 1; l < 50; l++)
- if (Harta[i, l] == -1)
- break;
- for (; l < 50; l++)
- if (Harta[i, l] != -1 && Harta[i, l] != Harta[i, j])
- {
- Harta01[Harta[i, j], Harta[i, l]] = 1;
- break;
- }
- //sus
- for (l = j - 1; l >= 0; l--)
- if (Harta[i, l] == -1)
- break;
- for (; l >= 0; l--)
- if (Harta[i, l] != -1 && Harta[i, l] != Harta[i, j])
- {
- Harta01[Harta[i, j], Harta[i, l]] = 1;
- break;
- }
- }
- }
- Size dimensiune = new Size(20, 20);
- for (i = 0; i < numarregiuni; i++)
- {
- //MessageBox.Show(i.ToString());
- culoriharta[i] = new TextBox();
- culoriharta[i].Size = dimensiune;
- culoriharta[i].Left = 535 + i * 22;
- culoriharta[i].Top = 70;
- Controls.Add(culoriharta[i]);
- culoriharta[i].Click += new EventHandler(culori_click);
- }
- solutii_BackTracking();
- for (i = 0; i < nrsolutii; i++)
- {
- for (j = 1; j <= numarregiuni; j++)
- {
- Lsolutii[i, j] = new Label();
- Lsolutii[i, j].BackColor = culoriharta[solutii[i, j-1]-1].BackColor;
- Lsolut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement