psotirov

Quadronacci Rectangle

Dec 29th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. class Quadronacci
  7. {
  8.     static void Main()
  9.     {
  10.         long[] Q = new long[400];
  11.         for (int i = 0; i < 4; i++)
  12.         {
  13.             Q[i] = long.Parse(Console.ReadLine());
  14.         }
  15.         int R = int.Parse(Console.ReadLine());
  16.         int C = int.Parse(Console.ReadLine());
  17.  
  18.         int total = R * C;
  19.         for (int i = 4; i < total; i++)
  20.         {
  21.             Q[i] = Q[i - 1] + Q[i - 2] + Q[i - 3] + Q[i - 4];
  22.         }
  23.  
  24.         for (int i = 0; i < R; i++)
  25.         {
  26.             for (int j = 0; j < C; j++)
  27.             {
  28.                 Console.Write(Q[i*C+j]);
  29.                 if (C - j > 1) Console.Write(" ");
  30.                 else Console.WriteLine();
  31.             }        
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment