Advertisement
adwas33

Untitled

Jun 15th, 2022
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. long double df(long double x, long double alfa,long double beta)
  8. {
  9. long double a= alfa *(x*x*x*x-beta);
  10. return a;
  11. }
  12.  
  13. int main() {
  14.  
  15. long double x0,y0,x,y,h;
  16. cout.precision(18);
  17. cout.setf(ios::fixed);
  18. x0=0;
  19. y0=1200;
  20. cout<<"Podaj czas"<<endl;
  21. cin>>x;
  22. cout<<"Podaj skok czasowy"<<endl;
  23. cin>>h;
  24. double alfa= -pow(10,-12);
  25. double beta=0;
  26. ofstream zapisDoPlikuWynikow("wyniki");
  27. ofstream zapisDoPlikuDanychWejsciowych("dane");
  28.  
  29. while(x0<x)
  30. {
  31.  
  32. y=y0+(h*df(y0,alfa,beta));
  33. zapisDoPlikuWynikow<<y<<endl;
  34. zapisDoPlikuDanychWejsciowych<<x0<<endl;
  35. y0=y;
  36. x0=x0+h;
  37.  
  38. }
  39. std::cout << "Wynik : "<<y<< std::endl;
  40. return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement