#include <iostream> #include <string> #include <stack> using namespace std; int main() { -stack<int> x; -x.push(5); -x.push(9); -x.push(32); -cout<< "stack size = " <<x.size()<<endl; -while(!x.empty()){ --cout<< "poping number "<< x.top() <<endl; --x.pop(); -} }
برنامج يطلب من المستخدم أن يدخل 10 أرقام ويسجل األرقام التي تم إدخالها على شكل Stack بحيث يوفر البرنامج للمستخدم عمل ) ()size(), top(), pop )لكن بدون استخدام أمر Stack الجاهز في اللغة )(. مالحظة : الهدف من التمرين هو عمل )Stack Implementing.
Problem statement
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
Cases:
()( -> Not Valid
() -> Valid
([]) -> Valid
( ->Not Valid
Input
1 <= s.length <= 10^4
s consists of parentheses only '()[]{}'.
Output
print true if the string is valid, otherwise print false.