Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Runtime.InteropServices;
- namespace _02._Boss_Rush
- {
- class Program
- {
- static void Main(string[] args)
- {
- Regex regex = new Regex(@"^[@][#]+(?<barcode>[A-Z][a-zA-Z0-9]{4,}[A-Z])[@][#]+$");
- int times = int.Parse(Console.ReadLine());
- //Dictionary<string, string> items = new Dictionary<string, string>();
- for (int i = 0; i < times; i++)
- {
- string input = Console.ReadLine();
- Match match = regex.Match(input);
- string sticker = "";
- if (match.Success)
- {
- string barcode = match.Groups["barcode"].Value;
- Regex digit = new Regex(@"[0-9]");
- MatchCollection number = digit.Matches(barcode);
- foreach (Match item in number)
- {
- //items[barcode] += item;
- sticker += item.Value;
- }
- if (number.Count == 0)
- {
- // items[barcode] = "00";
- sticker = "00";
- }
- Console.WriteLine($"Product group: {sticker}");
- }
- else
- {
- Console.WriteLine("Invalid barcode");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement