Untitled
unknown
plain_text
a year ago
778 B
1
Indexable
Never
using System; using System.Collections.Generic; namespace STack { class Program { static void Main(string[] args) { Stack<int> myStack = new Stack<int>(); string abc = "{}{}{{{}}}{"; for (int i =0; i<abc.Length; i++) { if (abc[i] == '{') myStack.Push(abc[i]); else if (abc[i] == '}') { if (myStack.Peek() == '{') myStack.Pop(); else myStack.Push(abc[i]); } } if (myStack.Count == 0) Console.WriteLine("Балансирани"); else Console.WriteLine("Небалансирани"); } } }