Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Text.RegularExpressions;
- class ShmoogleCounter
- {
- static void Main()
- {
- List<string> ints = new List<string>();
- List<string> doubles = new List<string>();
- while (true)
- {
- string line = Console.ReadLine();
- if (line == @"//END_OF_CODE")
- {
- break;
- }
- if (string.IsNullOrEmpty(line))
- {
- continue;
- }
- const string Pattern = @"(\b(int|double)\b \b([a-z][a-zA-Z]{0,24})\b)";
- MatchCollection matches = Regex.Matches(line, Pattern);
- foreach (Match match in matches)
- {
- if (match.Groups[1].Success)
- {
- if (match.Groups[2].Value == "int")
- {
- ints.Add(match.Groups[3].Value);
- }
- else
- {
- doubles.Add(match.Groups[3].Value);
- }
- }
- }
- }
- doubles.Sort();
- ints.Sort();
- Console.WriteLine(
- "Doubles: {0}{1}Ints: {2}",
- doubles.Count > 0 ? string.Join(", ", doubles) : "None",
- Environment.NewLine,
- ints.Count > 0 ? string.Join(", ", ints) : "None");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement