Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp1
- {
- public class Program
- {
- public static void Main()
- {
- string input = Console.ReadLine();
- string[] args = Console.ReadLine().Split();
- char searchedChar = args[0][0];
- int targetIndex = int.Parse(args[1]);
- List<int> indexesOfGivenChar = new List<int>();
- for (int i = 0; i < input.Length; i++)
- {
- if (input[i] == searchedChar)
- {
- indexesOfGivenChar.Add(i);
- }
- }
- if (indexesOfGivenChar.Count < targetIndex)
- {
- Console.WriteLine("Find the letter yourself!");
- }
- else
- {
- Console.WriteLine(indexesOfGivenChar[targetIndex-1]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement