Advertisement
ilian_test

Untitled

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