paranteze intermediar

This commit is contained in:
2025-12-12 13:00:48 +02:00
parent bf2e9c33be
commit 4edcc17a6b
+45 -1
View File
@@ -4,7 +4,51 @@
//([]) nu este corect, şirul ()]( nu este corect.
//
#include <iostream>
#include <stack>
std::string paranteze;
std::stack<char> stiva;
int ok=1;
void rotundeInchise(std::string paranteze);
int main() {
return 0;
std::cout <<"sir de paranteze = ";
std::cin >> paranteze;
bool acolada, patrata;
for (int i = 0; i < paranteze.size(); i++) {
if (paranteze[i] == '{') {
stiva.push('{');
}
else if (paranteze[i] == '[') {
stiva.push('[');
}
else if (paranteze[i] == '(')
stiva.push('(');
else {
if (paranteze[i] == ')' || paranteze[i] == ']' || paranteze[i] == '}') {
if(!stiva.empty()){
stiva.pop();
}
else {
std::cout<<"prea multe paranteze deschise \n";
ok=0;
break;
}
}
}
}
if (ok && stiva.empty()) {
std::cout << "toate sunt închise";
}
else {
std::cout << "nu sunt închise";
}
return 0;
}