Advertisement
Guest User

Array.cs

a guest
Jun 24th, 2013
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. namespace Hledani_min
  9. {
  10.  
  11.  
  12. class Array
  13. {
  14.  
  15. public int x = 20;
  16. public int y = 20;
  17. public int[,] pole;
  18. public int miny = 20;
  19. public bool obsazeno;
  20.  
  21.  
  22.  
  23.  
  24. //barvy
  25.  
  26. public Array()
  27. {
  28.  
  29.  
  30.  
  31. pole = new int[x, y];
  32.  
  33.  
  34.  
  35. }
  36.  
  37.  
  38.  
  39.  
  40. public void Obsazovani()
  41. {
  42.  
  43.  
  44.  
  45. //obsadi pole honotou
  46. //1 = mina
  47. //0 = skryte prazdne policko
  48. //2 = skryta mina
  49. //3 = prazdne policko
  50. Random random = new Random();
  51.  
  52. for (int d = 0; d < miny; )
  53. {
  54. int rndx = random.Next(x);
  55. int rndy = random.Next(y);
  56. if (pole[rndx, rndy] == 0)
  57. {
  58. pole[rndx, rndy] = 1;
  59. d++;
  60. }
  61. obsazeno = true;
  62. }
  63.  
  64.  
  65.  
  66.  
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement