Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _2.Array_Elements_Equal_to_Their_Index
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(' ');
- int[] numArray = new int[input.Length];
- int index = 0;
- string output = string.Empty;
- for (int i = 0; i < numArray.Length; i++)
- {
- numArray[i] = int.Parse(input[i]);
- if (numArray[i] == index)
- {
- output += input[i] + " ";
- }
- index++;
- }
- Console.WriteLine(output);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement