Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Debugging_Substring
- {
- using System;
- public class Substring_broken
- {
- public static void Main()
- {
- string text = Console.ReadLine();
- int jump = int.Parse(Console.ReadLine());
- const char Search = 'p';
- bool hasMatch = false;
- for (int i = 0; i < text.Length; i++)
- {
- if (text[i] == Search)
- {
- hasMatch = true;
- int length = jump + 1;
- string matchedString;
- if (i + length <= text.Length)
- {
- matchedString = text.Substring(i, length);
- }
- else
- {
- matchedString = text.Substring(i);
- }
- Console.WriteLine(matchedString);
- i += jump;
- }
- }
- if (!hasMatch)
- {
- Console.WriteLine("no");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement