main.c 610 B

123456789101112131415161718192021222324252627282930
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <math.h>
  6. #include <time.h>
  7. #include "header.h"
  8. double f(double x,int* c) {
  9. *c += 1;
  10. return pow(x, 5) - 2.9 * pow(x, 3) + 6.5 * pow(x, 2) - 7 * x;
  11. }
  12. int main() {
  13. double a = 0, b = 1.35,eps;
  14. int* cs;
  15. char path[100];
  16. FILE* file;
  17. for (int i = 0;i < 11;i++) {
  18. sprintf(path, "C:/Users/egorl/source/repos/gitbranch/num_methods_sem2/KR/KR/res/%i.txt",i);
  19. file = fopen(path,"w+");
  20. eps = pow(10, -i);
  21. cs = counters(f, a, b, eps);
  22. fprintf(file, "%d %d", cs[0], cs[1]);
  23. fclose(file);
  24. }
  25. return 0;
  26. }