rendered paste body#include <iostream>#include <string>#include <sstream>#include <algorithm> using namespace std; template <typename Iterator> void F1(string & str, Iterator begin, Iterator end){ Iterator i, temp, i1; int count = 0; float f; for ( ;; ) { count = 0 ; for (i = str.begin ();i != str.end ();++i) { if (*i == '(') { ++count; temp = i; } else if (*i == ')') { ++count; f=F(temp+1,i); ostringstream ss; ss << f ; string s = ss.str(); str.replace (temp+1,i,s) ; } } if (count == 0) return; }} template <typename Iterator> float F(Iterator begin, Iterator end){ Iterator i; if ((i = find(begin,end,'+')) != end) { return F(begin,i) + F(i+1,end) ; }else if ((i = find(begin,end,'-')) != end) { return F(begin,i) - F(i+1,end) ; }else if ((i = find(begin,end,'*')) != end) { return F(begin,i) * F(i+1,end) ; }else if ((i = find(begin,end,'/')) != end) { return F(begin,i) / F(i+1,end) ; }else { string str1(begin,end) ; istringstream stream(str1); float i; stream >> i; return i ; }} int main() { string str,str1; float a; getline(cin,str); F1(str,str.begin(),str.end()); a = F(str.begin(),str.end()); cout << "Ats: " << a << endl; cin.get();}