Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- var input = Console.ReadLine();
- var stack = new Stack<int>();
- for (int i = 0; i < input.Length; i++)
- {
- var ch = input[i];
- if (ch == '(')
- {
- stack.Push(i);
- }
- else if (ch == ')')
- {
- var startIndex = stack.Pop();
- var contents = input.Substring(
- startIndex, i - startIndex + 1);
- Console.WriteLine(contents);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement