first commit

This commit is contained in:
Nyagami
2022-12-15 23:51:04 +07:00
commit 87d51fb251
292 changed files with 12623 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import java.util.*;
public class non {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
Stack<Character> a = new Stack<>();
Stack<Character> b = new Stack<>();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '<') {
if (!a.empty())
b.push(a.pop());
} else if (s.charAt(i) == '>') {
if (!b.empty())
a.push(b.pop());
} else if (s.charAt(i) == '-') {
if (!a.empty())
a.pop();
} else
a.push(s.charAt(i));
}
while (!a.empty())
b.push(a.pop());
while (!b.empty())
System.out.print(b.pop());
}
}