Advertisement
Guest User

Untitled

a guest
Mar 10th, 2014
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. using System;
  2. //Write a program that prints an isosceles triangle of 9 copyright symbols ©, something like this:
  3. //   ©
  4. //  © ©
  5. // ©   ©
  6. //© © © ©
  7. //Note that the © symbol may be displayed incorrectly at the console so you may need to change the console character
  8. //encoding to UTF-8 and assign a Unicode-friendly font in the console. Note also, that under old versions of Windows
  9. //the © symbol may still be displayed incorrectly, regardless of how much effort you put to fix it.
  10.  
  11. class IsoscelesTriangle
  12. {
  13.    static void Main()
  14.     {
  15.         Console.WriteLine("Enter some number,which can't devide on 2 and bigger than 3(5,7,9 etc.)");
  16.         int cols = int.Parse(Console.ReadLine());
  17.         //int copyrightToInt = (int)'©';
  18.         char copyright = '©';
  19.         int count = 1;
  20.         Console.Write(new string(' ', cols / 2));
  21.         Console.Write(copyright);
  22.         Console.Write(new string(' ', cols / 2));
  23.         Console.WriteLine();
  24.         for (int i = cols / 2 ; i > 0; i--)
  25.         {
  26.             if (i!=1)
  27.             {
  28.                 Console.Write(new string(' ', i - 1));
  29.                 Console.Write(copyright);
  30.                 Console.Write(new string(' ', count));
  31.                 Console.Write(copyright);
  32.                 Console.Write(new string(' ', i - 1));
  33.                 Console.WriteLine();
  34.                 count += 2;
  35.             }
  36.             else if (i == 1)
  37.             {
  38.                 for (int y = 0; y < cols; y++)
  39.                 {
  40.                     if (y % 2 != 0)
  41.                     {
  42.                         Console.Write(' ');
  43.                     }
  44.                     else
  45.                     {
  46.                         Console.Write(copyright);
  47.                     }
  48.                 }
  49.             }
  50.         }
  51.         Console.WriteLine();
  52.         Console.WriteLine("Cool Isn't it?");
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement