lmarkov

IsoscelesTriangle

Nov 21st, 2012
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. /*
  2.  Write a program that prints an isosceles triangle of 9
  3.  * copyright symbols ©. Use Windows Character
  4.  * Map to find the Unicode code of the © symbol.
  5.  * Note: the © symbol may be displayed incorrectly.
  6.  */
  7.  
  8. using System;
  9.  
  10. class IsoscelesTriangle
  11. {
  12.     static void Main()
  13.     {
  14.         char copyrightChar = '\u00A9';
  15.         int rows = 3;
  16.         int cols = 4;
  17.  
  18.         for (rows = 1; rows < cols; rows++)
  19.         {
  20.             if(rows == 1)
  21.             {
  22.                 for (int line = 1; line < cols - rows; line++)
  23.                 {
  24.                     Console.Write(" ");
  25.                 }
  26.                 Console.WriteLine("{0}",copyrightChar);
  27.             }
  28.  
  29.             if (rows == 2)
  30.             {
  31.                 for (int line = 1; line < cols - rows; line++)
  32.                 {
  33.                     Console.Write(" ");
  34.                 }
  35.                 Console.WriteLine("{0}{0}{0}",copyrightChar);                
  36.             }
  37.  
  38.             if (rows == 3)
  39.             {
  40.                 for (int line = 1; line < cols - rows; line++)
  41.                 {
  42.                     Console.Write(" ");
  43.                 }
  44.                 Console.WriteLine("{0}{0}{0}{0}{0}\n", copyrightChar);
  45.             }            
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment