Advertisement
Teodor92

Quadro

Dec 30th, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Numerics;
  4.  
  5. class Tribonacci
  6. {
  7.     static void Main()
  8.     {
  9.         BigInteger firstElement = BigInteger.Parse(Console.ReadLine());
  10.         BigInteger secondElement = BigInteger.Parse(Console.ReadLine());
  11.         BigInteger thirdElement = BigInteger.Parse(Console.ReadLine());
  12.         BigInteger fourthElement = BigInteger.Parse(Console.ReadLine());
  13.         int row = int.Parse(Console.ReadLine());
  14.         int col = int.Parse(Console.ReadLine());
  15.         List<BigInteger> allNums = new List<BigInteger>();
  16.         BigInteger sum = 0;
  17.         allNums.Add(firstElement);
  18.         allNums.Add(secondElement);
  19.         allNums.Add(thirdElement);
  20.         allNums.Add(fourthElement);
  21.         for (int i = 0; i < (col*row) - 4; i++)
  22.         {
  23.             sum = firstElement + secondElement + thirdElement + fourthElement;
  24.             allNums.Add(sum);
  25.             firstElement = secondElement;
  26.             secondElement = thirdElement;
  27.             thirdElement = fourthElement;
  28.             fourthElement = sum;
  29.         }
  30.         for (int i = 0; i < allNums.Count; i++)
  31.         {
  32.             if (i % col == 0 && i != 0)
  33.             {
  34.                 Console.WriteLine();
  35.             }
  36.             Console.Write("{0} ",allNums[i]);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement