Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Se dau n șiruri de paranteze rotunde. Să se stabilească, despre fiecare șir, dacă este corect parantezat – adică dacă parantezele se închid corect.
- #include <fstream>
- #include <cstring>
- #include <stack>
- using namespace std;
- ifstream fin("prntz.in");
- ofstream fout("prntz.out");
- int n;
- stack<char> St;
- int main()
- {
- fin >> n;
- char t[25];
- for (int i = 0; i < n; i ++)
- {
- fin >> t;
- for (int j = 0; j < strlen(t); j ++)
- if (t[j] == '(')
- St.push(t[j]);
- else
- St.pop();
- if (St.empty())
- fout << 1 << endl;
- else
- fout << 0 << endl;
- }
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement