Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. double f(double x){
  8. return x + 4 / (x + 0.3) - sin(x) - 3;
  9. }
  10.  
  11. double max1(double a, double b, double h){
  12. ifstream input("output.txt");
  13. double x = a;
  14. double m;
  15. while (x <= b){
  16. double b;
  17. input >> b;
  18. if (x == a){
  19. input >> m;
  20. }else{
  21. double val;
  22. input >> val;
  23. if (val > m){
  24. m = val;
  25. }
  26. }
  27. x += h;
  28. }
  29. return m;
  30. }
  31. int main()
  32. {
  33. double a, b, h;
  34. cin >> a >> b >> h;
  35. ofstream output("output.txt");
  36. double x = a;
  37. while ( x <= b){
  38. output << x << " " << f(x) << endl;
  39. x += h;
  40. }
  41. cout << max1(a, b, h);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement