Advertisement
Guest User

zadanie c# - odwrocona litera N

a guest
Apr 1st, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. //Rextester.Program.Main is the entry point for your code. Don't change it.
  2. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text.RegularExpressions;
  8.  
  9. namespace Rextester
  10. {
  11.     public class Program
  12. {
  13.     const char CHAR = '*';
  14.     static void Star() {Console.Write(CHAR);}
  15.     static void Starno() {Console.Write('◈');}
  16.     static void StarLn() {  Console.WriteLine(CHAR); }
  17.     static void Space() { Console.Write(" ");}
  18.     static void SpaceLn() { Console.WriteLine(" ");}
  19.     static void NewLine() { Console.WriteLine();}
  20.  
  21.  
  22.     public static void LiteraX(int n)
  23.     {
  24.         if (n < 3) throw new ArgumentException("zbyt mały rozmiar");
  25.         if (n % 2 == 0) n = n + 1;
  26.  
  27.         //górna połówka
  28.         for (int i = 0; i < n-1 ; i++)
  29.         {
  30.             Star();
  31.             for (int j = 2; j < n  -  i; j++)
  32.             {
  33.                 Space();
  34.             }
  35.             Star();
  36.             for (int j =  i+2; j > 2 ; j--)
  37.             {
  38.                 Space();
  39.             }
  40.             StarLn();
  41.          
  42.            
  43.         }
  44.          
  45.     }
  46.    
  47.  
  48.     public static void Main(string[] args)
  49.     {
  50.  
  51.         LiteraX(18);
  52.  
  53.     }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement