Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HomeWork 3 SoftUni
- Problem 8. Isosceles Triangle
- using System;
- namespace Triangle
- {
- class Program
- {
- static void Main(string[] args)
- { //Problem 8. Isosceles Triangle
- Console.WriteLine("Problem 8. Isosceles Triangle VARIANT 2");
- Console.WriteLine();
- Console.WriteLine("Please input the number of rows and columns of the triangle:");
- int i, j;
- char copyRight = '\u00a9';
- int heigh = int.Parse(Console.ReadLine());
- char[][] copyRightTriangle = new char[heigh + 1][];
- for (i = 0; i < heigh; i++)
- {
- copyRightTriangle[i] = new char[i + 1];
- }
- //пълним матрицата
- for (i = 0; i < heigh; i++)
- {
- for (j = 0; j < i; j++)
- {
- if (j == 0 || j == (i - 1) || i == (heigh - 1))
- {
- copyRightTriangle[i][j] = copyRight;
- }
- }
- }
- for (i = 0; i < heigh; i++)
- {
- Console.Write("".PadLeft((heigh - i) * 2));
- for (j = 0; j <= i; j++)
- {
- Console.Write("{0,3} ", copyRightTriangle[i][j]);
- }
- Console.WriteLine();
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement