Advertisement
radidim

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

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