Viacheslav

TelerikAlphaExamOctober11Problem02CrookedStairs

Oct 12th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Problem02
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             long brickOne = long.Parse(Console.ReadLine());
  10.             long brickTwo = long.Parse(Console.ReadLine());
  11.             long brickThree = long.Parse(Console.ReadLine());
  12.             long countOfRows = long.Parse(Console.ReadLine());
  13.             Console.WriteLine(brickOne);
  14.             Console.WriteLine("{0} {1}", brickTwo, brickThree);
  15.  
  16.             for (int i = 3; i <= countOfRows; i++)
  17.             {
  18.                 for (int k = 1; k <= i; k++)
  19.                 {
  20.                     long currentBrick = brickThree + brickTwo + brickOne;
  21.                     brickOne = brickTwo;
  22.                     brickTwo = brickThree;
  23.                     brickThree = currentBrick;
  24.                     if (k == i)
  25.                     {
  26.                         Console.Write(currentBrick);
  27.                     }
  28.                     else
  29.                     {
  30.                         Console.Write(currentBrick);
  31.                         Console.Write(" ");
  32.                     }
  33.                 }
  34.                 Console.WriteLine();
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment