Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace NthChar
- {
- public class StartUp
- {
- public static void Main()
- {
- string input = Console.ReadLine();
- string[] data = Console.ReadLine().Split();
- char charToFind = data[0][0];
- int occurrences = int.Parse(data[1]);
- var result = input.Select((c, i) => new { Char = c, Index = i })
- .Where(item => item.Char == charToFind)
- .Skip(occurrences - 1)
- .FirstOrDefault();
- Console.WriteLine(result?.Index.ToString()?? "Find the letter yourself!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement