Advertisement
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();
- int jump = int.Parse(Console.ReadLine());
- bool hasMatch = false;
- for (int i = 0; i < text.Length; i++)
- {
- if (text[i] == 'p')
- {
- hasMatch = true;
- int endIndex = jump + 1;
- if (endIndex + i > text.Length)
- {
- endIndex = text.Length - i;
- }
- string matchedString = text.Substring(i, endIndex);
- Console.WriteLine(matchedString);
- i += endIndex;
- }
- }
- if (!hasMatch)
- {
- Console.WriteLine("no");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement