Advertisement
Kuncavia

Quattronacci

Nov 28th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2.     class Program
  3.     {
  4.         static void Main()
  5.         {
  6.             long firstNum = long.Parse(Console.ReadLine());
  7.             long secondNum = long.Parse(Console.ReadLine());
  8.             long thirdNum = long.Parse(Console.ReadLine());
  9.             long forthNum = long.Parse(Console.ReadLine());
  10.             int rows = int.Parse(Console.ReadLine());
  11.             int cols = int.Parse(Console.ReadLine());
  12.             long result = 0
  13.  
  14.             if (cols == 4)
  15.             {
  16.             Console.WriteLine(firstNum + " " + secondNum + " " + thirdNum + " " + forthNum);
  17.             }
  18.             else
  19.             {
  20.                 Console.Write(firstNum + " " + secondNum + " " + thirdNum + " " + forthNum + " ");
  21.             }
  22.  
  23.             for (int i = 0; i < rows; i++)
  24.             {
  25.                 int currentCols = 0;
  26.                 if (i == 0)
  27.                 {
  28.                     currentCols = 4;
  29.                 }
  30.                 for (int y = currentCols; y < cols; y++)
  31.                 {
  32.                     resut = firstNum + secondNum + thirdNum + forthNum;
  33.                     firstNum = secondNum;
  34.                     secondNum = thirdNum;
  35.                     thirdNum = forthNum;
  36.                     forthNum = result;
  37.  
  38.                     if (y + 1 == cols)
  39.                     {
  40.                         Console.WriteLine(result);
  41.                     }
  42.                     else
  43.                     {
  44.                         Console.Write(reuslt + " ");
  45.                     }
  46.                 }
  47.             }
  48.         }
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement