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;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- namespace _03ShmoogleCounter
- {
- class Program
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine();
- // string myString = text.Replace(System.Environment.NewLine, " ");
- string pattern = @"\bint\b \b([a-z][a-zA-Z]{0,24})\b";
- Regex regex = new Regex(pattern);
- Match match = regex.Match(text);
- List<string> result = new List<string>();
- MatchCollection matches = Regex.Matches(text, pattern);
- string none = "None";
- string pattern2 = @"\bdouble\b \b([a-z][a-zA-Z]{0,24})\b";
- Regex regex2 = new Regex(pattern2);
- List<string> result2 = new List<string>();
- //int countInt = 0;
- Match match2 = regex2.Match(text);
- MatchCollection matches2 = Regex.Matches(text, pattern2);
- // MatchCollection matches2 = Regex.Matches(text, pattern2);
- while (text != "//END_OF_CODE")
- {
- if (regex.IsMatch(text))
- {
- // match = regex.Match(text);
- matches = Regex.Matches(text, pattern);
- foreach (Match mat in matches)
- {
- //Console.WriteLine(match.Value);
- result.Add(mat.Groups[1].Value);
- // countInt++;
- }
- }
- else if (regex2.IsMatch(text))
- {
- match2 = regex2.Match(text);
- matches2 = Regex.Matches(text, pattern2);
- foreach (Match item in matches2)
- {
- result2.Add(item.Groups[1].Value);
- // match2 = match2.NextMatch();
- }
- }
- // match = match.NextMatch();
- text = Console.ReadLine();
- }
- // Console.WriteLine(5);
- //result.Add(match.Groups[1].Value);
- //countInt = Regex.Matches(text, pattern).Count;
- // match = match.NextMatch();
- //text =Console.ReadLine();
- result.Sort();
- result2.Sort();
- Console.Write("Doubles: ");
- if (result2.Count != 0)
- {
- Console.WriteLine(string.Join(", ", result2));
- }
- else
- {
- Console.WriteLine("None");
- }
- Console.Write("Ints: ");
- if (result.Count != 0)
- {
- Console.WriteLine(string.Join(", ", result));
- }
- else
- {
- Console.WriteLine("None");
- }
- // Console.WriteLine(countInt);
- // if text.Contains("int");
- // Console.WriteLine("Doubles: None");
- // Console.WriteLine("Ints: None");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement