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;
- namespace Problem_15.Star__Balanced_Brackets
- {
- class BalancedBrackets
- {
- static void Main(string[] args)
- {
- int input = int.Parse(Console.ReadLine());
- int countOpenBracket = 0;
- int countClosingBRacket = 0;
- for (int i = 1; i <= input; i++)
- {
- string text = Console.ReadLine();
- foreach (char openBracket in text)
- {
- if (openBracket == '(')
- {
- countOpenBracket++;
- }
- if (openBracket == ')')
- {
- countClosingBRacket++;
- }
- }
- }
- if (countOpenBracket == countClosingBRacket)
- {
- Console.WriteLine("BALANCED");
- }
- else
- {
- Console.WriteLine("UNBALANCED");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement