Advertisement
YavorGrancharov

Array_Elements_Equal_to_Their_Index

Jun 23rd, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Array_Elements_Equal_to_Their_Index
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] array = Console.ReadLine()
  14.                 .Split()
  15.                 .Select(int.Parse)
  16.                 .ToArray();
  17.  
  18.             string index = string.Empty;
  19.  
  20.             for (int i = 0; i < array.Length; i++)
  21.             {
  22.               if (i == array[i])
  23.                 {
  24.                     index += i + " ";
  25.                 }
  26.             }
  27.             Console.WriteLine(index);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement