Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace _06.BalancedBrackets3
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- StringBuilder text = new StringBuilder();
- Regex regex = new Regex(@"^([^(\)]*\([^(\)]*\)[^(\)]*)*$");
- for (int i = 0; i < n; i++)
- {
- string line = Console.ReadLine();
- text.Append(line);
- }
- Match match = regex.Match(text.ToString());
- if (match.Success)
- {
- Console.WriteLine("BALANCED");
- }
- else
- {
- Console.WriteLine("UNBALANCED");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment