Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <iomanip>
- #include <string>
- using namespace std;
- const int MAX=20;
- int main()
- {
- double stos[MAX];
- int pomocnicza=0;
- string x;
- double a,b;
- stringstream abc;
- while(true)
- {
- cin>>x;
- if(x=="=")
- break;
- abc.str("");
- abc.clear();
- abc<<x; //UMIESZCZENIE W STRUMIEN
- if(abc>>a)
- stos[pomocnicza++]=a; //UMIESZCZENIE NA STOSIE JESLI ARGUMENTEM JEST LICZBA
- else
- {
- b = stos[--pomocnicza];
- a = stos[--pomocnicza];
- switch(x[0])
- {
- case '+' : a += b; break;
- case '-' : a -= b; break;
- case '*' : a *= b; break;
- case '/' : a /= b; break;
- }
- stos[pomocnicza++] = a; //UMIESZCZENIE NA STOSIE
- }
- }
- cout<< stos[--pomocnicza] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement