Advertisement
Guest User

Untitled

a guest
Feb 10th, 2019
947
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_ZigZagArrays
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int n = int.Parse(Console.ReadLine());
  11.  
  12.             string[] firstLineOutput = new string[n];
  13.             string[] secondLineOutput = new string[n];
  14.  
  15.             for (int i = 1; i <= n; i++)
  16.             {
  17.                 string[] input = Console.ReadLine().Split().ToArray();
  18.  
  19.                 if (i % 2 != 0)
  20.                 {
  21.                     firstLineOutput[i - 1] = input[0];
  22.                     secondLineOutput[i - 1] = input[1];
  23.                 }
  24.  
  25.                 else
  26.                 {
  27.                     firstLineOutput[i - 1] = input[1];
  28.                     secondLineOutput[i - 1] = input[0];
  29.                 }
  30.             }
  31.  
  32.             Console.WriteLine(String.Join(" ", firstLineOutput));
  33.             Console.WriteLine(String.Join(" ", secondLineOutput));
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement