Advertisement
ntodorova

27.12-02.TribonacciTriangle

Dec 31st, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using System;
  2.  
  3. class TribonacciTriangle
  4. {
  5.     static void Main()
  6.     {
  7.         long first = long.Parse(Console.ReadLine());
  8.         long second = long.Parse(Console.ReadLine());
  9.         long third = long.Parse(Console.ReadLine());
  10.  
  11.         byte L = byte.Parse(Console.ReadLine());
  12.  
  13.         for (int i = 0; i < L; i++)
  14.         {
  15.             for (int j = 0; j <= i; j++)
  16.             {
  17.                 long newNum = first + second + third;
  18.  
  19.                 if (j > 0)
  20.                 {
  21.                     Console.Write(' ');
  22.                 }
  23.  
  24.                 Console.Write(first);
  25.  
  26.                 first = second;
  27.                 second = third;
  28.                 third = newNum;
  29.             }
  30.  
  31.             Console.WriteLine();
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement