Advertisement
Stann

QuadronacciRectanlge

Apr 2nd, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.28 KB | None | 0 0
  1. using System;
  2. class QuadranacciRectanlge
  3. {
  4.     static void Main()
  5.     {
  6.         long a = long.Parse(Console.ReadLine());
  7.         long b = long.Parse(Console.ReadLine());
  8.         long c = long.Parse(Console.ReadLine());
  9.         long d = long.Parse(Console.ReadLine());
  10.         byte rows = byte.Parse(Console.ReadLine());
  11.         byte cols = byte.Parse(Console.ReadLine());
  12.         byte n = 4;
  13.         long nextNum = 0;
  14.         if (cols == n)
  15.         {
  16.             Console.WriteLine("{0} {1} {2} {3}", a, b, c, d);
  17.             for (int i = 0; i < rows - 1; i++)
  18.             {
  19.                 for (int j = 0; j < cols; j++)
  20.                 {
  21.                     nextNum = a + b + c + d;
  22.                     a = b;
  23.                     b = c;
  24.                     c = d;
  25.                     d = nextNum;
  26.                     Console.Write(nextNum);
  27.                     if(j < cols-1) //Ignore the last space
  28.                     {
  29.                         Console.Write(" ");
  30.                     }
  31.                 }
  32.                 if(i < rows - 2) //Ignore the last empty line
  33.                 {
  34.                     Console.WriteLine();
  35.                 }
  36.             }
  37.         }
  38.         else
  39.         {
  40.             Console.Write("{0} {1} {2} {3} ", a, b, c, d);
  41.             for (int i = n; i < cols; i++)
  42.             {
  43.                 nextNum = a + b + c + d;
  44.                 a = b;
  45.                 b = c;
  46.                 c = d;
  47.                 d = nextNum;
  48.                 Console.Write(nextNum);
  49.                 if(i < cols -1)
  50.                 {
  51.                     Console.Write(" ");
  52.                 }
  53.             }
  54.             Console.WriteLine();
  55.             for (int i = 0; i < rows - 1; i++)
  56.             {
  57.                 for (int j = 0; j < cols; j++)
  58.                 {
  59.                     nextNum = a + b + c + d;
  60.                     a = b;
  61.                     b = c;
  62.                     c = d;
  63.                     d = nextNum;
  64.                     Console.Write(nextNum);
  65.                     if (j < cols - 1)
  66.                     {
  67.                         Console.Write(" ");
  68.                     }
  69.                 }
  70.                 if (i < rows - 2)
  71.                 {
  72.                     Console.WriteLine();
  73.                 }
  74.             }
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement