Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. int num, r, c, H = 0;
  2.  
  3.  
  4.  
  5.             char ds;
  6.  
  7.  
  8.  
  9.             Random rnd = new Random();
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.             do
  18.  
  19.             {
  20.  
  21.  
  22.  
  23.                 Console.WriteLine("Scrivi un numero compreso tra 1 e 20");
  24.  
  25.  
  26.  
  27.                 num = Convert.ToInt16(Console.ReadLine());
  28.  
  29.  
  30.  
  31.             }
  32.  
  33.  
  34.  
  35.             while (num > 20 | num < 0);
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.             for (r = 1; r <= num; r++) //incremento
  44.  
  45.             {
  46.  
  47.  
  48.  
  49.                 for (c = num + 1 - (r + 1); c >= 0; c--)
  50.  
  51.                 {
  52.  
  53.                     Console.ForegroundColor = ConsoleColor.Cyan;
  54.  
  55.                     Console.Write("-");
  56.  
  57.  
  58.  
  59.                 }
  60.  
  61.  
  62.  
  63.                 for (c = 1; c <= r; c++)
  64.  
  65.                 {
  66.  
  67.  
  68.  
  69.                     H = rnd.Next(1, 10);
  70.  
  71.  
  72.  
  73.                     if (H < 2)
  74.  
  75.                     {
  76.  
  77.                         Console.ForegroundColor = ConsoleColor.Red;
  78.  
  79.                         ds = '*';
  80.  
  81.  
  82.  
  83.                     }
  84.  
  85.  
  86.  
  87.                     else if (H < 9)
  88.  
  89.                     {
  90.  
  91.                         Console.ForegroundColor = ConsoleColor.Green;
  92.  
  93.                         ds = 'o';
  94.  
  95.  
  96.  
  97.                     }
  98.  
  99.  
  100.  
  101.                     else
  102.  
  103.                     {
  104.  
  105.                         Console.ForegroundColor = ConsoleColor.Yellow;
  106.  
  107.                         ds = 'x';
  108.  
  109.  
  110.  
  111.                     }
  112.  
  113.  
  114.  
  115.                     Console.Write(ds);
  116.  
  117.  
  118.  
  119.                 }
  120.  
  121.  
  122.  
  123.                 for (c = 1; c < r; c++)
  124.  
  125.                 {
  126.  
  127.  
  128.  
  129.                     H = rnd.Next(1, 10);
  130.  
  131.  
  132.  
  133.                     if (H < 2)
  134.  
  135.                     {
  136.  
  137.                         Console.ForegroundColor = ConsoleColor.Red;
  138.  
  139.                         ds = '*';
  140.  
  141.  
  142.  
  143.                     }
  144.  
  145.  
  146.  
  147.                     else if (H < 9)
  148.  
  149.                     {
  150.  
  151.                         Console.ForegroundColor = ConsoleColor.Green;
  152.  
  153.                         ds = 'o';
  154.  
  155.  
  156.  
  157.                     }
  158.  
  159.  
  160.  
  161.                     else
  162.  
  163.                     {
  164.  
  165.                         Console.ForegroundColor = ConsoleColor.Yellow;
  166.  
  167.                         ds = 'x';
  168.  
  169.  
  170.  
  171.                     }
  172.  
  173.  
  174.  
  175.                     Console.Write(ds);
  176.  
  177.  
  178.  
  179.                 }
  180.  
  181.  
  182.  
  183.                 for (c = num + 1 - (r + 1); c >= 0; c--)
  184.  
  185.                 {
  186.  
  187.                     Console.ForegroundColor = ConsoleColor.Cyan;
  188.  
  189.                     Console.Write("-");
  190.  
  191.  
  192.  
  193.                 }
  194.  
  195.  
  196.  
  197.                 Console.WriteLine();
  198.  
  199.             }
  200.  
  201.  
  202.  
  203.             for (int t = 1; t <= (num / 4); t++) //tronco
  204.  
  205.             {
  206.  
  207.                 for (c = num + 1 - (r + 1); c > 0; c--)
  208.  
  209.                 {
  210.  
  211.                     Console.ForegroundColor = ConsoleColor.Cyan;
  212.  
  213.                     Console.Write("-");
  214.  
  215.                 }
  216.  
  217.                 for (r = 1; r < num; r++)
  218.  
  219.                 {
  220.  
  221.                     Console.ForegroundColor = ConsoleColor.Cyan;
  222.  
  223.                     Console.Write("-");
  224.  
  225.                 }
  226.  
  227.  
  228.  
  229.                     Console.ForegroundColor = ConsoleColor.DarkYellow;
  230.  
  231.                     Console.Write("888");
  232.  
  233.  
  234.  
  235.                 for (r = 1; r < num; r++)
  236.  
  237.                 {
  238.  
  239.                     Console.ForegroundColor = ConsoleColor.Cyan;
  240.  
  241.                     Console.Write("-");
  242.  
  243.                 }
  244.  
  245.                 Console.WriteLine();
  246.  
  247.             }
  248.  
  249.  
  250.  
  251.             Console.ReadLine();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement