Advertisement
Guest User

jd

a guest
Nov 12th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 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. using System.Threading;
  7. namespace ConsoleApp5
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Random rnd = new Random();
  14.  
  15. string cialoWeza = ">";
  16. const int LiczbaNagrod = 10;
  17. int wiersz = 10;
  18. int sumaPunktow = 0;
  19. //tab - tablica dla wartosci pozycji (kolumny) oraz znaku dla kazdej nagrody
  20. int[,] tab = new int[LiczbaNagrod, 2];
  21.  
  22. //Wypisujemy nagrody
  23. for (int i = 0; i < tab.GetLength(0); i++)
  24. {
  25. tab[i, 0] = rnd.Next(0, Console.WindowWidth);
  26. tab[i, 1] = rnd.Next(65, 91);
  27. Console.SetCursorPosition(tab[i, 0], wiersz);
  28. Console.WriteLine((char)tab[i, 1]);
  29. }
  30.  
  31. int kolumna = 0;
  32. do
  33. {
  34. for (int i = 0; i < tab.GetLength(0); i++)
  35. {
  36. if (tab[i, 0] == kolumna) //tu jest nagroda
  37. {
  38. sumaPunktow += 1; // (tab[i, 1] % 5 == 0 ? 10 :2;
  39. cialoWeza = (Convert.ToChar(tab[i, 1])) + cialoWeza;
  40. }
  41. }
  42. Console.SetCursorPosition(Math.Max(0, kolumna - (cialoWeza.Length + 1)), wiersz);
  43. Console.WriteLine(" " + cialoWeza);
  44. kolumna++;
  45. Console.SetCursorPosition(0, Console.WindowHeight - 2);
  46. Console.WriteLine("Liczba punktów: {0}", sumaPunktow);
  47. Thread.Sleep(150);
  48. } while (kolumna < Console.WindowWidth);
  49. }
  50.  
  51.  
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement