Advertisement
ivan_yosifov

Quadronacci_Rectangle

Nov 14th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.    
  6.     static void Main()
  7.     {
  8.         long n1 = long.Parse(Console.ReadLine());
  9.         long n2 = long.Parse(Console.ReadLine());
  10.         long n3 = long.Parse(Console.ReadLine());
  11.         long n4 = long.Parse(Console.ReadLine());
  12.         int row = int.Parse(Console.ReadLine());
  13.         int col = int.Parse(Console.ReadLine());
  14.  
  15.         int total = row * col;
  16.         long[] arr = new long[total];
  17.  
  18.         long sum = 0L;
  19.         arr[0] = n1;
  20.         arr[1] = n2;
  21.         arr[2] = n3;
  22.         arr[3] = n4;
  23.  
  24.         for (int i = 4; i < total; i++)
  25.         {
  26.             sum = n1 + n2 + n3 + n4;
  27.             arr[i] = sum;
  28.             n1 = n2;
  29.             n2 = n3;
  30.             n3 = n4;
  31.             n4 = sum;
  32.         }
  33.  
  34.         for (int i = 0; i < total; i++)
  35.         {            
  36.            
  37.             if (i != 0)
  38.             {
  39.                 if ((i % (total / row)) == 0)
  40.                 {
  41.                     Console.WriteLine();
  42.                 }
  43.             }
  44.             Console.Write(arr[i] + " ");
  45.         }
  46.  
  47.  
  48.         Console.WriteLine();
  49.     }
  50.  
  51.    
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement