Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace _3._Camera_View
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] nums = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int skipM = nums[0];
- int takeN = nums[1];
- string input = Console.ReadLine();
- List<string> finalWords = new List<string>();
- for (int i = 0; i < input.Length; i++)
- {
- string takeWord = "";
- if (input[i] == '|' && input[i + 1] == '<')
- {
- for (int j = i + 2; j < input.Length; j++)
- {
- if (input[j] == '|' && input[j + 1] == '<')
- {
- break;
- }
- takeWord += input[j];
- }
- if(takeWord.Length < (takeN + skipM))
- {
- int shorterTakeN = (takeWord.Length - skipM);
- takeWord = takeWord.Substring(skipM, shorterTakeN);
- }
- else
- {
- takeWord = takeWord.Substring(skipM, takeN);
- }
- }
- if (takeWord.EndsWith('|'))
- {
- takeWord = takeWord.TrimEnd('|');
- }
- if(takeWord != "")
- {
- finalWords.Add(takeWord);
- }
- }
- Console.WriteLine(string.Join(", ", finalWords));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement