archangelmihail

QuadronacciRectangle

Nov 30th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 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. using System.Numerics;
  7.  
  8. namespace Quadronacci_Rectangle
  9. {
  10.     class QuadronacciRectangle
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             BigInteger first = BigInteger.Parse(Console.ReadLine());
  15.             BigInteger second = BigInteger.Parse(Console.ReadLine());
  16.             BigInteger third = BigInteger.Parse(Console.ReadLine());
  17.             BigInteger fourth = BigInteger.Parse(Console.ReadLine());
  18.             bool start = true;
  19.             BigInteger current = 0;
  20.             int rows = int.Parse(Console.ReadLine());
  21.             int cols = int.Parse(Console.ReadLine());
  22.             if (cols == 4 && start)
  23.             {
  24.                 Console.Write(first + " " + second + " " + third + " " + fourth);
  25.             }
  26.             else if (cols > 4 && start)
  27.             {
  28.                 Console.Write(first + " " + second + " " + third + " " + fourth + " ");
  29.             }
  30.             for (int i = 0; i < rows; i++)
  31.             {
  32.                 for (int j = 0; j < cols; j++)
  33.                 {
  34.                     if (start)
  35.                     {
  36.                         j = 3;
  37.                         start = false;
  38.                         continue;
  39.                     }
  40.                     current = first + second + third + fourth;
  41.                     if (i == rows -1 && j == cols - 1)
  42.                     {
  43.                         Console.Write(current);
  44.                         break;
  45.                     }
  46.                     else if (j == cols - 1)
  47.                     {
  48.                         Console.Write(current);
  49.                     }
  50.                     else if (j != cols - 1)
  51.                     {
  52.                         Console.Write(current + " ");
  53.                     }
  54.                     first = second;
  55.                     second = third;
  56.                     third = fourth;
  57.                     fourth = current;
  58.                 }
  59.                 Console.WriteLine();
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment