Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main(int argc, const char * argv[]) {
- int l=0, s=0;
- string c;
- getline(cin, c);
- for (int i=0; i<c.length(); i++) {
- if (c[i] == '(') l++;
- else {
- l--;
- if (c[i-1] == '(') s += l;
- else s++;
- }
- }
- cout << s ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement