Advertisement
Guest User

Untitled

a guest
Dec 27th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleApp1
  5. {
  6. public class Program
  7. {
  8. public static void Main()
  9. {
  10. string input = Console.ReadLine();
  11. string[] args = Console.ReadLine().Split();
  12.  
  13. char searchedChar = args[0][0];
  14. int targetIndex = int.Parse(args[1]);
  15.  
  16. List<int> indexesOfGivenChar = new List<int>();
  17.  
  18. for (int i = 0; i < input.Length; i++)
  19. {
  20. if (input[i] == searchedChar)
  21. {
  22. indexesOfGivenChar.Add(i);
  23. }
  24. }
  25.  
  26. if (indexesOfGivenChar.Count < targetIndex)
  27. {
  28. Console.WriteLine("Find the letter yourself!");
  29. }
  30. else
  31. {
  32. Console.WriteLine(indexesOfGivenChar[targetIndex-1]);
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement