Skip to content

Instantly share code, notes, and snippets.

@kunishi
Created October 8, 2015 02:31
Show Gist options
  • Save kunishi/0e4e81059731a1e8f915 to your computer and use it in GitHub Desktop.
Save kunishi/0e4e81059731a1e8f915 to your computer and use it in GitHub Desktop.
#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