Advertisement
radidim

03.Zig-Zag Arrays (C# Shell App Paste)

Dec 26th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. namespace CSharp_Shell
  7. {
  8.  
  9.     public static class Program
  10.     {
  11.         public static void Main()
  12.         {
  13.            int n = int.Parse(Console.ReadLine());
  14.            int[] arrA = new int[n];
  15.            int[] arrB = new int[n];
  16.            
  17.            for(int i=0; i<n;i++)
  18.            {
  19.               int[] arr = Console.ReadLine()
  20.                .Split()
  21.                .Select(int.Parse)
  22.                .ToArray();
  23.                
  24.                
  25.                if(i%2!=0)
  26.                {
  27.                    arrA[i] = arr[0];
  28.                    arrB[i] = arr[1];
  29.                    
  30.                }
  31.                
  32.                else
  33.                {
  34.                    arrA[i] =arr[1];
  35.                    arrB[i] = arr[0];
  36.                    
  37.                }
  38.            }
  39.            
  40.            Console.WriteLine(string.Join(" ", arrA));
  41.            Console.WriteLine(string.Join(" ", arrB));
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement