o_ignatov

03 camera view

Jun 30th, 2017
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace _03CameraView
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. int[] nums = Console.ReadLine().Split().Select(int.Parse).ToArray();
  15. int skip = nums[0];
  16. int take = nums[1];
  17.  
  18. string pattern = @"(?!\|)<(?<pics>[a-zA-Z]*)";
  19. string input = Console.ReadLine();
  20. MatchCollection matchedResult = Regex.Matches(input, pattern);
  21. List<string> res = new List<string>();
  22. foreach (Match m in matchedResult)
  23. {
  24. res.Add(m.Groups["pics"].Value);
  25. }
  26. List<string> result = new List<string>();
  27. for (int i = 0; i < res.Count; i++)
  28. {
  29. if (res[i].Length <= skip)
  30. {
  31. continue;
  32. }
  33. else if (res[i].Length >= skip + take)
  34. {
  35. result.Add(res[i].Substring(skip, take));
  36. }
  37. else
  38. {
  39. result.Add(res[i].Remove(0, skip));
  40. }
  41. }
  42. Console.WriteLine(string.Join(", ", result));
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment