Advertisement
YavorGrancharov

Find_the_Letter(text_processing)

Jul 30th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Find_the_Letter
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string input = Console.ReadLine();
  10.             var chars = string.Join(string.Empty, input).ToCharArray();
  11.  
  12.             string[] indexer = Console.ReadLine().Split(' ');
  13.  
  14.             int count = 0;
  15.             for (int i = 0; i < chars.Length; i++)
  16.             {
  17.                 char letter = char.Parse(indexer[0]);
  18.                 int position = int.Parse(indexer[1]);
  19.  
  20.                 if (chars[i] == letter)
  21.                 {
  22.                     count++;
  23.                     if (count == position)
  24.                     {
  25.                         Console.WriteLine(i);
  26.                         return;
  27.                     }
  28.                 }
  29.             }
  30.             Console.WriteLine("Find the letter yourself!");
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement