Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [StartCode]
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp8
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int bracket = 0;
- foreach (var sumbol in "(())((()))")
- {
- if (sumbol == '(')
- {
- bracket++;
- Console.WriteLine("Вложенность "+ bracket);
- }
- else if (bracket < 0 )
- {
- Console.WriteLine("Строка не корректная .");
- }
- else
- {
- bracket--;
- }
- }
- if (bracket == 0)
- {
- Console.WriteLine("Строка корректная .");
- }
- else
- {
- Console.WriteLine("Строка не корректная");
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment