Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 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 trojkat_trojkat_kwadrat
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Random rnd = new Random();
  14. Console.WriteLine("Jaką figurę mam wydrukować");
  15. Console.WriteLine("1-kwadrat/2-odwrócony trójkąt/3-trójkąt");
  16. int w = int.Parse(Console.ReadLine());
  17. Console.WriteLine("Podaj wymiary figury");
  18. int x = int.Parse(Console.ReadLine());
  19. Console.WriteLine(" ");
  20. switch (w)
  21. {
  22. case 1:
  23. for (int a = 1; a <= x; ++a)
  24. {
  25. Console.WriteLine();
  26. for (int b = 1; b <= x; ++b)
  27. {
  28. int mnozenie = a * b;
  29. {
  30. int liczba = rnd.Next(10, 100);
  31. if (liczba <= 100) Console.ForegroundColor = ConsoleColor.DarkMagenta;
  32. if (liczba <= 90) Console.ForegroundColor = ConsoleColor.DarkRed;
  33. if (liczba <= 80) Console.ForegroundColor = ConsoleColor.Cyan;
  34. if (liczba <= 70) Console.ForegroundColor = ConsoleColor.White;
  35. if (liczba <= 60) Console.ForegroundColor = ConsoleColor.Green;
  36. if (liczba <= 50) Console.ForegroundColor = ConsoleColor.Red;
  37. if (liczba <= 40) Console.ForegroundColor = ConsoleColor.Magenta;
  38. if (liczba <= 30) Console.ForegroundColor = ConsoleColor.Yellow;
  39. if (liczba <= 20) Console.ForegroundColor = ConsoleColor.Blue; ;
  40. Console.Write(liczba + " ");
  41. }
  42.  
  43. }
  44. }
  45.  
  46. break;
  47.  
  48. case 2:
  49. for (int a = 1; a <= x; ++a)
  50. {
  51. Console.WriteLine();
  52. for (int b = 1; b <= a; ++b)
  53. {
  54. int mnozenie = a * b;
  55. if (mnozenie < 10)
  56. {
  57. Console.Write(" " + mnozenie + " ");
  58. }
  59. else
  60. {
  61. Console.Write(mnozenie + " ");
  62. }
  63. }
  64. }
  65. break;
  66. case 3:
  67. for (int a = x; a >= 1; --a)
  68. {
  69. Console.WriteLine();
  70. for (int b = a; b >= 1; --b)
  71. {
  72. int mnozenie = a * b;
  73. if (mnozenie < 10)
  74. {
  75. Console.Write(" " + mnozenie + " ");
  76. }
  77. else
  78. {
  79. Console.Write(mnozenie + " ");
  80. }
  81. }
  82. }
  83. break;
  84. }
  85. Console.ReadKey(true);
  86. }
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement