Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ArrayElementsEqualtoTheirIndex
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int[] numbers = Console.ReadLine().Split().Select(int.Parse).ToArray();
- List<int> result = new List<int>();
- for (int i = 0; i < numbers.Length; i++)
- {
- if (numbers[i] == i)
- {
- result.Add(numbers[i]);
- }
- }
- Console.WriteLine(string.Join(" ",result));
- }
- }
- }
Add Comment
Please, Sign In to add comment