Created
October 8, 2015 02:31
-
-
Save kunishi/0e4e81059731a1e8f915 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
#include <sstream> | |
#include <list> | |
using namespace std; | |
int main() | |
{ | |
char c; | |
int sum; | |
string expr, str; | |
int count; | |
int n; | |
while (!cin.eof()) { | |
if (cin.peek() != ' ') { | |
if (expr != "") { | |
istringstream is(expr); | |
list<int> list; | |
count = 0; | |
while (!is.eof()) { | |
c = is.peek(); | |
if (c == ' ') { | |
is.get(); | |
} else if (c == '(') { | |
is.get(); | |
count ++; | |
} else if (c == ')') { | |
is.get(); | |
count --; | |
} else { | |
is >> n; | |
list.push_back(n); | |
} | |
} | |
} | |
cin >> sum >> ws; | |
getline(cin, str); | |
expr = str; | |
} else { | |
cin >> ws; | |
getline(cin, str); | |
expr += str; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment