Problem p00087 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define pb(n) push_back(n)
#define mp(n, m) make_pair(n, m)
#define fi first
#define se second
#define all(r) (r).begin(), (r).end()

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int IMAX = ((1 << 30) - 1) * 2 + 1;
const double EPS = 1e-10;
// int mod=1000000007;

vector<string> split(string s, char c) {
  stringstream ss(s);
  string t;
  vector<string> ret;
  while (getline(ss, t, c)) {
    ret.pb(t);
  }
  return ret;
}

int main() {
  string s;
  vector<string> v;
  string ope[4] = {"+", "-", "*", "/"};
  while (getline(cin, s)) {
    v = split(s, ' ');
    stack<double> t;
    double a, b, c;
    for (int i = 0; i < v.size(); i++) {
      for (int j = 0; j < 4; j++) {
        if (v[i] == ope[j]) {
          a = t.top();
          t.pop();
          b = t.top();
          t.pop();
          if (j == 0)
            c = b + a;
          else if (j == 1)
            c = b - a;
          else if (j == 2)
            c = b * a;
          else
            c = (double)b / a;
          t.push(c);
          break;
        }
        if (j == 3) {
          c = atof(v[i].c_str());
          t.push(c);
        }
      }
    }
    printf("%.15lf\\n", t.top());
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, e) for (int i = (s); i < (e); i++)
#define pb(n) push_back((n))
#define mp(n, m) make_pair((n), (m))
#define all(r) r.begin(), r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

vector<string> split(const string s, char c) {
  vector<string> ret;
  string t;
  stringstream ss(s);
  while (getline(ss, t, c)) {
    ret.push_back(t);
  }
  return ret;
}

int main() {
  string s;
  while (getline(cin, s)) {
    vector<string> vs = split(s, ' ');
    stack<double> t;
    double a, b;
    for (int i = 0; i < vs.size(); i++) {
      if (vs[i][0] == '+') {
        a = t.top();
        t.pop();
        b = t.top();
        t.pop();
        t.push(a + b);
      } else if (vs[i][0] == '-') {
        a = t.top();
        t.pop();
        b = t.top();
        t.pop();
        t.push(b - a);
      } else if (vs[i][0] == '*') {
        a = t.top();
        t.pop();
        b = t.top();
        t.pop();
        t.push(a * b);
      } else if (vs[i][0] == '/') {
        a = t.top();
        t.pop();
        b = t.top();
        t.pop();
        t.push((double)b / a);
      } else {
        t.push(atof(vs[i].c_str()));
      }
    }
    printf("%.15lf\\n", t.top());
  }
}