l5.cpp 818 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <iostream>
  2. #include <string>
  3. int main() {
  4. int s = 0;
  5. while(s <= 3) {
  6. std::string pol;
  7. std::cout << "Знак" << std::endl;
  8. std::cin >> pol;
  9. double x1;
  10. std::cout << "Первое число" << std::endl;
  11. std::cin >> x1;
  12. double x2;
  13. std::cout << "Второе число" << std::endl;
  14. std::cin >> x2;
  15. if(pol == "+") {
  16. std::cout << x1 << pol << x2 << "=" << x1+x2 << std::endl;
  17. s++;
  18. }
  19. else if(pol == "-") {
  20. std::cout << x1 << pol << x2 << "=" << x1-x2 << std::endl;
  21. s++;
  22. }
  23. else if(pol == "*") {
  24. std::cout << x1 << pol << x2 << "=" << x1*x2 << std::endl;
  25. s++;
  26. }
  27. else if(pol == "/") {
  28. std::cout << x1 << pol << x2 << "=" << x1/x2 << std::endl;
  29. s++;
  30. }
  31. else {
  32. std::cout << "Неверный знак" << std::endl;
  33. return 0;
  34. }
  35. }
  36. return 0;
  37. }