Advertisement
VyaraG

Rectangle

Nov 30th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2. //Write a program which asks for a number, a width and a height and displays a rectangle of that width and that height, using that number for the inner symbol, as in this example:
  3.  
  4. //Enter a number: 4
  5. //Enter the desired width: 3
  6. //Enter the desired height: 5
  7.  
  8. //444
  9. //444
  10. //444
  11. //444
  12. //444
  13.  
  14.  
  15. class Program
  16. {
  17.     static void Main()
  18.     {
  19.         char number = char.Parse(Console.ReadLine()); //could be entered a number(resp - with an int declared)
  20.         int width = int.Parse(Console.ReadLine());
  21.         int height = int.Parse(Console.ReadLine());
  22.  
  23.         for (int i = 1; i <= height; i++)
  24.         {
  25.             for (int j = 1; j <=width; j++)
  26.             {
  27.                 Console.Write(number);
  28.             }
  29.             Console.WriteLine();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement