TheBulgarianWolf

Zig-zag arrays

Oct 13th, 2020
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Linq;
  5. using System.Numerics;
  6.  
  7. namespace SoftuniExercisesWithVariables
  8. {
  9.     class Program
  10.     {
  11.        
  12.  
  13.         static void Main(string[] args)
  14.         {
  15.             Console.WriteLine("Enter number of lines you want:  ");
  16.             int lines = int.Parse(Console.ReadLine());
  17.             int[] arrayOfNums1 = new int[lines];
  18.             int[] arrayOfNums2 = new int[lines];
  19.            
  20.             int count = 0;
  21.             while(lines>0)
  22.             {
  23.                 int[] array = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
  24.                 if(count % 2 == 0)
  25.                 {
  26.                     arrayOfNums1[count] = array[0];
  27.                     arrayOfNums2[count] = array[1];
  28.  
  29.                 }
  30.                 else
  31.                 {
  32.                     arrayOfNums1[count] = array[1];
  33.                     arrayOfNums2[count] = array[0];
  34.                 }
  35.                 lines--;
  36.                 count++;
  37.             }
  38.            
  39.             foreach(int i in arrayOfNums1)
  40.             {
  41.                 Console.Write(i + " ");
  42.             }
  43.             Console.WriteLine();
  44.             foreach(int l in arrayOfNums2)
  45.             {
  46.                 Console.Write(l + " ");
  47.             }
  48.         }
  49.     }
  50. }
  51.  
Add Comment
Please, Sign In to add comment