Guest User

Untitled

a guest
Oct 21st, 2019
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <fstream>
  4. #include <math.h>
  5. #pragma warning( disable : 4996 )
  6. using namespace std;
  7.  
  8. double f(int r , double x)
  9. {
  10. return r * x * (1 - x);
  11. }
  12.  
  13. int main()
  14. {
  15. char filename[100];
  16. for (int r = 1; r <= 4; r++)
  17. {
  18. sprintf(filename, "data%d.txt", r);
  19. int n = 0;
  20. FILE* FL;
  21. FL = fopen(filename, "w");
  22. double x0 = 0.1;
  23. double x00 = 0.2;
  24. double x000 = 0.3;
  25. double x0000 = 0.4;
  26.  
  27. for (n; n <= 10; n++) {
  28. fprintf(FL, "%d %f %f %f %f \n", n, f(r, x0), f(r, x00), f(r, x000), f(r, x0000));
  29. double x1 = f(r, x0), x11 = f(r, x00), x111 = f(r, x000), x1111 = f(r, x0000);
  30. x0 = x1, x00 = x11, x000 = x111, x0000 = x1111;
  31. }
  32.  
  33. fclose(FL);
  34. }
  35. }
RAW Paste Data