Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Substring_broken
- {
- public static void Main()
- {
- string text = Console.ReadLine();
- string result = string.Empty;
- int jump = int.Parse(Console.ReadLine());
- int symbol = 112;
- bool hasMatch = false;
- for (int i = 0; i < text.Length; i++)
- {
- int step = jump;
- if (text[i] == symbol)
- {
- hasMatch = true;
- while (true)
- {
- try
- {
- result = text.Substring(i, step+ 1);
- i += jump;
- Console.WriteLine(result);
- break;
- }
- catch (Exception ex)
- {
- step--;
- }
- }
- }
- }
- if (!hasMatch)
- {
- Console.WriteLine("no");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment