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 Wzorki
- {
- class Program
- {
- const char CHAR = '*';
- static void Star() => Console.Write(CHAR);
- static void StarLn() => Console.WriteLine(CHAR);
- static void Space() => Console.Write(" ");
- static void SpaceLn() => Console.WriteLine(" ");
- static void NewLine() => Console.WriteLine();
- public static void Trojkat(int n)
- {
- if (n % 2 == 0) n = n - 1;
- //górna podstawa
- for (int i = 0; i < n; i++)
- {
- Star();
- }
- NewLine();
- //środek
- for (int i = 1; i < (n / 2); i++)
- {
- for (int j = 0; j < i; j++)
- {
- Space();
- }
- Star();
- for (int j = n - 2 - (2 * i); j > 0; j--)
- {
- Space();
- }
- StarLn();
- }
- //czubek
- if (n % 2 == 1)
- {
- for (int i = 0; i < n / 2; i++)
- {
- Space();
- }
- StarLn();
- }
- }
- public static void Main(string[] args)
- {
- Console.WriteLine("Podaj rozmiar figury: ");
- int n = Convert.ToInt32(Console.ReadLine());
- Trojkat(n);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement