PolinaKoleva

QuadronacciRectangle

Dec 29th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.     class QuadronacciRectangle
  4.     {
  5.         static void Main()
  6.         {
  7.             BigInteger n1 = BigInteger.Parse(Console.ReadLine());
  8.             BigInteger n2 = BigInteger.Parse(Console.ReadLine());
  9.             BigInteger n3 = BigInteger.Parse(Console.ReadLine());
  10.             BigInteger n4 = BigInteger.Parse(Console.ReadLine());
  11.             int row = int.Parse(Console.ReadLine());
  12.             int col = int.Parse(Console.ReadLine());
  13.             BigInteger[] m = new BigInteger[row*col+1];
  14.             m[0] = n1;
  15.             m[1] = n2;
  16.             m[2] = n3;
  17.             m[3] = n4;
  18.                 for (int j = 3; j <(row*col); j++)
  19.                 {
  20.                     m[j+1] = m[j] + m[j - 1] + m[j - 2] + m[j - 3];
  21.                 }
  22.  
  23.                 int count = 1;
  24.                 for (int j=0; j < (col*row); j++)
  25.                 {
  26.                     Console.Write(m[j]+" ");
  27.                    
  28.                     if (j + 1 ==count*col)
  29.                     {
  30.                         Console.WriteLine();
  31.                         count++;
  32.                     }
  33.                 }
  34.         }
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment