会津オンラインジャッジ(AOJ)にコードを提出するとcompile errorとなってしまいます。
しかし、vs2015上では同内容を実行できて、中身も正解しているように見えます。
どうすればcompile errorが直るでしょうか。
以下が問題のURLです。
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=jp
###エラーメッセージ
code.cpp: In function ‘int main()’: code.cpp:43:14: error: ‘stoi’ was not declared in this scope i = stoi(s); ^
###該当のソースコード
#include<iostream> #include<string> using namespace std; class myStack { public: void push(int x) { S[++top] = x; } int pop() { top--; return S[top + 1]; } private: int top = 0; int S[1000] = { 0 }; }; int main() { string s; myStack sta; std::cin >> s; while (!std::cin.eof()) { if (s[0] == '+') { int a = sta.pop(); int b = sta.pop(); sta.push(b + a); } else if (s[0] == '-') { int a = sta.pop(); int b = sta.pop(); sta.push(b - a); } else if (s[0] == '*') { int a = sta.pop(); int b = sta.pop(); sta.push(b * a); } else { int i; i = stoi(s); sta.push(i); } std::cin >> s; } cout << sta.pop() << endl; return 0; }
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。