Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s:
- string input;
- int a = 0;
- int Tcount = 0;
- Stack ch = new Stack();
- Console.WriteLine("Input Anything :");
- input = Console.ReadLine();
- foreach (char c in input)
- {
- if (c.Equals('('))
- {
- ch.Push('(');
- Tcount += 1;
- }
- else if (c.Equals(')'))
- {
- try
- {
- ch.Pop();
- a++;
- }
- catch(Exception)
- {
- Console.WriteLine("( is expected");
- Console.ReadLine();
- goto s;
- }
- }
- }
- if (ch.Count == 0)
- {
- Console.WriteLine(Tcount + " valid ");
- }
- else
- {
- Console.WriteLine( ") is expected");
- }
- goto s;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement