Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace AplicatiiLee
  12. {
  13. public partial class Form1 : Form
  14. {
  15. Graphics g;
  16. Label[,] Lsolutii = new Label[21, 21];
  17. int[,] solutii = new int[21, 21];
  18. public static int dimensiunematrice = 51;
  19. int[,] Harta = new int[dimensiunematrice, dimensiunematrice];
  20. int[,] Harta01 = new int[21, 21];
  21. int[,] Harta_originala = new int[dimensiunematrice, dimensiunematrice];
  22. int nrsolutii = 0, xmousevechi = 0, ymousevechi = 0, deseneaza = 0, numarregiuni = 0;
  23. public TextBox[] culoriharta = new TextBox[100];
  24. public Form1()
  25. {
  26. InitializeComponent();
  27. g = pictureBox1.CreateGraphics();
  28. }
  29.  
  30. private void Form1_Click(object sender, EventArgs e)
  31. {
  32.  
  33. }
  34.  
  35. private void button1_Click(object sender, EventArgs e)
  36. {
  37. int i, j, l;
  38. string s="";
  39. for (i = 0; i < dimensiunematrice; i++)
  40. for (j = 0; j < dimensiunematrice; j++)
  41. if(Harta[i,j]==0)
  42. {
  43. s = "";
  44. numarregiuni++;
  45. //MessageBox.Show(numarregiuni.ToString());
  46. FILL(i, j, numarregiuni);
  47. /*for (int ii = 0; ii < dimensiunematrice; ii++)
  48. {
  49. for (int jj = 0; jj < dimensiunematrice; jj++)
  50. s = s + Harta[ii, jj] + " ";
  51. s = s + "\n";
  52. }
  53. MessageBox.Show(s);*/
  54. }
  55. for (i = 0; i < numarregiuni; i++)
  56. for (j = 0; j < numarregiuni; j++)
  57. Harta01[i, j] = 0;
  58. for (i = 0; i < 50; i++)
  59. for (j = 0; j < 50; j++)
  60. {
  61. if (Harta[i, j] > 0)
  62. {
  63. //dreapta
  64. for (l = i + 1; l < 50; l++)
  65. if (Harta[l, j] == -1)
  66. break;
  67. for (; l < 50; l++)
  68. if (Harta[l, j] != -1 && Harta[l, j] != Harta[i, j])
  69. {
  70. Harta01[Harta[i, j], Harta[l, j]] = 1;
  71. break;
  72. }
  73. //stanga
  74. for (l = i - 1; l >= 0; l--)
  75. if (Harta[l, j] == -1)
  76. break;
  77. for (; l >= 0; l--)
  78. if (Harta[l, j] != -1 && Harta[l, j] != Harta[i, j])
  79. {
  80. Harta01[Harta[i, j], Harta[l, j]] = 1;
  81. break;
  82. }
  83. //jos
  84. for (l = j + 1; l < 50; l++)
  85. if (Harta[i, l] == -1)
  86. break;
  87. for (; l < 50; l++)
  88. if (Harta[i, l] != -1 && Harta[i, l] != Harta[i, j])
  89. {
  90. Harta01[Harta[i, j], Harta[i, l]] = 1;
  91. break;
  92. }
  93. //sus
  94. for (l = j - 1; l >= 0; l--)
  95. if (Harta[i, l] == -1)
  96. break;
  97. for (; l >= 0; l--)
  98. if (Harta[i, l] != -1 && Harta[i, l] != Harta[i, j])
  99. {
  100. Harta01[Harta[i, j], Harta[i, l]] = 1;
  101. break;
  102. }
  103. }
  104. }
  105. Size dimensiune = new Size(20, 20);
  106. for (i = 0; i < numarregiuni; i++)
  107. {
  108. //MessageBox.Show(i.ToString());
  109. culoriharta[i] = new TextBox();
  110. culoriharta[i].Size = dimensiune;
  111. culoriharta[i].Left = 535 + i * 22;
  112. culoriharta[i].Top = 70;
  113. Controls.Add(culoriharta[i]);
  114. culoriharta[i].Click += new EventHandler(culori_click);
  115. }
  116. solutii_BackTracking();
  117.  
  118. for (i = 0; i < nrsolutii; i++)
  119. {
  120. for (j = 1; j <= numarregiuni; j++)
  121. {
  122. Lsolutii[i, j] = new Label();
  123. Lsolutii[i, j].BackColor = culoriharta[solutii[i, j-1]-1].BackColor;
  124. Lsolut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement