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 trojkat_trojkat_kwadrat
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rnd = new Random();
- Console.WriteLine("Jaką figurę mam wydrukować");
- Console.WriteLine("1-kwadrat/2-odwrócony trójkąt/3-trójkąt");
- int w = int.Parse(Console.ReadLine());
- Console.WriteLine("Podaj wymiary figury");
- int x = int.Parse(Console.ReadLine());
- Console.WriteLine(" ");
- switch (w)
- {
- case 1:
- for (int a = 1; a <= x; ++a)
- {
- Console.WriteLine();
- for (int b = 1; b <= x; ++b)
- {
- int mnozenie = a * b;
- {
- int liczba = rnd.Next(10, 100);
- if (liczba <= 100) Console.ForegroundColor = ConsoleColor.DarkMagenta;
- if (liczba <= 90) Console.ForegroundColor = ConsoleColor.DarkRed;
- if (liczba <= 80) Console.ForegroundColor = ConsoleColor.Cyan;
- if (liczba <= 70) Console.ForegroundColor = ConsoleColor.White;
- if (liczba <= 60) Console.ForegroundColor = ConsoleColor.Green;
- if (liczba <= 50) Console.ForegroundColor = ConsoleColor.Red;
- if (liczba <= 40) Console.ForegroundColor = ConsoleColor.Magenta;
- if (liczba <= 30) Console.ForegroundColor = ConsoleColor.Yellow;
- if (liczba <= 20) Console.ForegroundColor = ConsoleColor.Blue; ;
- Console.Write(liczba + " ");
- }
- }
- }
- break;
- case 2:
- for (int a = 1; a <= x; ++a)
- {
- Console.WriteLine();
- for (int b = 1; b <= a; ++b)
- {
- int mnozenie = a * b;
- if (mnozenie < 10)
- {
- Console.Write(" " + mnozenie + " ");
- }
- else
- {
- Console.Write(mnozenie + " ");
- }
- }
- }
- break;
- case 3:
- for (int a = x; a >= 1; --a)
- {
- Console.WriteLine();
- for (int b = a; b >= 1; --b)
- {
- int mnozenie = a * b;
- if (mnozenie < 10)
- {
- Console.Write(" " + mnozenie + " ");
- }
- else
- {
- Console.Write(mnozenie + " ");
- }
- }
- }
- break;
- }
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement