Advertisement
Yurka21

miniGame

May 16th, 2021
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp2
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. Random r = new Random();
  10.  
  11. int goodCount = r.Next(4, 15);
  12.  
  13. for (int i = 0; i < Console.WindowWidth * (Console.WindowHeight - 3); i++)
  14. {
  15. Console.Write('C');
  16. }
  17.  
  18. int rectWidth = 10;
  19. int rectHeight = 10;
  20.  
  21. int countRaw = Console.WindowWidth / rectWidth;
  22.  
  23. for (int i = 0; i < goodCount; i++)
  24. {
  25. int rectLeftUpX = rectWidth * (i % goodCount);
  26. int rectLeftUpY = i / countRaw;
  27.  
  28. int x = r.Next(rectLeftUpX, rectLeftUpX + rectWidth);
  29. int y = r.Next(rectLeftUpY, rectLeftUpY + rectHeight);
  30.  
  31. Console.SetCursorPosition(x, y);
  32. Console.Write('S');
  33. }
  34.  
  35. Console.SetCursorPosition(0, Console.WindowHeight -1);
  36. Console.WriteLine("Сколько 'C' Вы видите?");
  37. int answer = Convert.ToInt32(Console.ReadLine());
  38.  
  39. if(answer == goodCount)
  40. {
  41. Console.WriteLine("Все верно, у Вас отличное зрение!");
  42. }
  43. else
  44. {
  45. Console.WriteLine("Увы, но Вы не угадали! Их - " + goodCount );
  46. }
  47.  
  48. Console.ReadLine();
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement