Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp6
- {
- class Program
- {
- static void Main(string[] args)
- {
- {
- int[,] pole = new int[10, 10];
- string[] pompole = new string[2];
- Random rnd = new Random();
- int PocetPokusu;
- Console.WriteLine("Zadej počet pokusů");
- PocetPokusu = int.Parse(Console.ReadLine());
- int pozice_1 = 0;
- int pozice_2 = 0;
- int PocetLodi = 5;
- for (int j = 0; j < pole.GetLength(0); j++)
- {
- for (int u = 0; u < pole.GetLength(1); u++)
- {
- pole[j, u] = 0;
- }
- }
- for (int i = 0; i < 5; i++)
- {
- pozice_1 = rnd.Next(0, pole.GetLength(1));
- pozice_2 = rnd.Next(0, pole.GetLength(0));
- if (pole[pozice_1, pozice_2] != 1)
- {
- pole[pozice_1, pozice_2] = 1;
- }
- else
- {
- i--;
- }
- }
- for (int j = 0; j < pole.GetLength(0); j++)
- {
- for (int u = 0; u < pole.GetLength(1); u++)
- {
- Console.Write("{0} ,", pole[j, u]);
- }
- Console.WriteLine();
- }
- for (int k = 1; k <= PocetPokusu; k++)
- {
- Console.Clear();
- for (int i = 0; i < pole.GetLength(0); i++)
- {
- for (int j = 0; j < pole.GetLength(1); j++)
- {
- Console.Write("{0},", pole[i, j]);
- }
- Console.WriteLine();
- }
- Console.WriteLine("Zadej řádek, sloupec");
- pompole = Console.ReadLine().Split(',');
- pozice_1 = Convert.ToInt32(pompole[0]) - 1;
- pozice_2 = Convert.ToInt32(pompole[1]) - 1;
- switch (pole[pozice_1, pozice_2])
- {
- case 0: Console.WriteLine("Voda"); pole[pozice_1, pozice_2] = 2; break;
- case 1: Console.WriteLine("Zásah"); pole[pozice_1, pozice_2] = 3; PocetLodi--; break;
- default: Console.WriteLine("Sem už jsi střílel"); break;
- }
- if (PocetLodi == 0)
- {
- Console.WriteLine("Vyhrál jsi");
- break;
- }
- }
- Console.WriteLine();
- Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement