archangelmihail

TribonaccTriangle

Nov 27th, 2013
72
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. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TribonaccTriangle
  8. {
  9.     class TribonaccTriangle
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             long one = long.Parse(Console.ReadLine());
  14.             long two = long.Parse(Console.ReadLine());
  15.             long three = long.Parse(Console.ReadLine());
  16.             int rows = int.Parse(Console.ReadLine());
  17.             long[] numbers = new long [1330];
  18.            
  19.             for (int i = 3; i < 1330; i++)
  20.             {
  21.                 numbers[0] = one;
  22.                 numbers[1] = two;
  23.                 numbers[2] = three;
  24.                 numbers[i] = numbers[i - 1] + numbers[i - 2] + numbers[i - 3];
  25.             }
  26.             int count = 0;
  27.             for (int i = 1; i <= rows; i++)
  28.             {
  29.  
  30.                 for (int j = count; j < count + i; j++)
  31.                 {
  32.                     Console.Write("{0} ", numbers[j]);
  33.                      
  34.                 }
  35.                 count += i;
  36.                 Console.WriteLine();
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment