Advertisement
Guest User

Příště nehraj HS kokote

a guest
Oct 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp6
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. {
  14. int[,] pole = new int[10, 10];
  15. string[] pompole = new string[2];
  16. Random rnd = new Random();
  17. int PocetPokusu;
  18. Console.WriteLine("Zadej počet pokusů");
  19. PocetPokusu = int.Parse(Console.ReadLine());
  20. int pozice_1 = 0;
  21. int pozice_2 = 0;
  22. int PocetLodi = 5;
  23. for (int j = 0; j < pole.GetLength(0); j++)
  24. {
  25. for (int u = 0; u < pole.GetLength(1); u++)
  26. {
  27. pole[j, u] = 0;
  28.  
  29. }
  30.  
  31. }
  32. for (int i = 0; i < 5; i++)
  33. {
  34. pozice_1 = rnd.Next(0, pole.GetLength(1));
  35. pozice_2 = rnd.Next(0, pole.GetLength(0));
  36. if (pole[pozice_1, pozice_2] != 1)
  37. {
  38. pole[pozice_1, pozice_2] = 1;
  39. }
  40. else
  41. {
  42. i--;
  43. }
  44. }
  45. for (int j = 0; j < pole.GetLength(0); j++)
  46. {
  47. for (int u = 0; u < pole.GetLength(1); u++)
  48. {
  49. Console.Write("{0} ,", pole[j, u]);
  50. }
  51. Console.WriteLine();
  52. }
  53. for (int k = 1; k <= PocetPokusu; k++)
  54. {
  55. Console.Clear();
  56. for (int i = 0; i < pole.GetLength(0); i++)
  57. {
  58. for (int j = 0; j < pole.GetLength(1); j++)
  59. {
  60. Console.Write("{0},", pole[i, j]);
  61. }
  62. Console.WriteLine();
  63. }
  64. Console.WriteLine("Zadej řádek, sloupec");
  65. pompole = Console.ReadLine().Split(',');
  66. pozice_1 = Convert.ToInt32(pompole[0]) - 1;
  67. pozice_2 = Convert.ToInt32(pompole[1]) - 1;
  68.  
  69. switch (pole[pozice_1, pozice_2])
  70. {
  71. case 0: Console.WriteLine("Voda"); pole[pozice_1, pozice_2] = 2; break;
  72. case 1: Console.WriteLine("Zásah"); pole[pozice_1, pozice_2] = 3; PocetLodi--; break;
  73. default: Console.WriteLine("Sem už jsi střílel"); break;
  74. }
  75.  
  76. if (PocetLodi == 0)
  77. {
  78. Console.WriteLine("Vyhrál jsi");
  79. break;
  80. }
  81. }
  82. Console.WriteLine();
  83. Console.ReadLine();
  84. }
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement