dosseva

FUND_03.Zig-Zag Arrays

Mar 7th, 2021 (edited)
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace ListManipulationAdvanced
  6. {
  7.     class Program
  8.     {
  9.         static void Main()
  10.         {
  11.             int number = int.Parse(Console.ReadLine());
  12.  
  13.             int[] firstArray = new int[number];
  14.             int[] secondArray = new int[number];
  15.  
  16.             for (int index = 0; index < number; index++)
  17.             {
  18.                 int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
  19.  
  20.                 if (index % 2 == 0)
  21.                 {
  22.                     firstArray[index] = input[0];
  23.                     secondArray[index] = input[1];
  24.                 }
  25.                 else
  26.                 {
  27.                     secondArray[index] = input[0];
  28.                     firstArray[index] = input[1];
  29.                 }
  30.             }
  31.  
  32.             Console.WriteLine(string.Join(" ", firstArray));
  33.             Console.WriteLine(string.Join(" ", secondArray));
  34.         }
  35.     }
  36. }
Add Comment
Please, Sign In to add comment