AOJ0087 Strange Mathematical Expression
逆ポーランド記法の問題
stackを用いる.
gist.github.com
C++で一行入力をするには
string s,tmp; getline(cin,s);//文字列sに一行入力 //cin.eof()空だったらtrue stringstream ss(s); while(ss >> tmp){ //空白で区切られたモノに分割する //一つの単位がtmpになる }
文字列をdouble型にする
atof(tmp.c_str());
tmpはstring型で直接関数atof()に渡せないので.c_str()メソッドを用いる.
atof()関数は文字列をdouble型にする.