fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. char a;
  7. float q,w;
  8. while(cin >> q >> w >> a)
  9. {
  10. if ( a=='+' )
  11. cout << q+w << endl;
  12. else if ( a=='-' )
  13. cout << q-w << endl;
  14. else if ( a=='*' )
  15. cout << q*w << endl;
  16. else if ( a=='/' )
  17. {
  18. if ( w==0 )
  19. cout << "MALFORMED" << endl;
  20. else
  21. cout << q/w << endl;
  22. }
  23.  
  24. else
  25. cout << "MALFORMED" << endl;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 2864KB
stdin
1 3 /
stdout
0.333333