Add dist
This commit is contained in:
parent
7393b9b49a
commit
896c925c11
19 changed files with 1102 additions and 0 deletions
44
2025.05.09/dist/Krivoruchenko_SK/a04.c
vendored
Normal file
44
2025.05.09/dist/Krivoruchenko_SK/a04.c
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "init_f.h"
|
||||
#include "solve.h"
|
||||
|
||||
/* ./a04.out a b n k */
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
double t, integral, a, b;
|
||||
int k, n, calls, task = 4;
|
||||
|
||||
double (*f_lst[]) (double) = {f0, f1, f2, f3, f4, f5, f6};
|
||||
int len_f = sizeof(f_lst) / sizeof(f_lst[0]);
|
||||
|
||||
if (
|
||||
!((argc == 5) &&
|
||||
sscanf(argv[1], "%lf", &a) == 1 &&
|
||||
sscanf(argv[2], "%lf", &b) == 1 &&
|
||||
((sscanf(argv[3], "%d", &n) == 1) && (n > 0)) &&
|
||||
((sscanf(argv[4], "%d", &k) == 1) && ((0 <= k) && (k < len_f))))
|
||||
) {
|
||||
fprintf(stderr, "Usage: %s a b n k\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
t = clock();
|
||||
integral = t4_solve(f_lst[k], a, b, n);
|
||||
t = (clock() - t) / CLOCKS_PER_SEC;
|
||||
|
||||
calls = get_call_count();
|
||||
|
||||
if (fabs(integral - DBL_MAX) < DBL_EPSILON) {
|
||||
fprintf (stdout, "%s : Task = %d Method is not applicable Count = %d T = %.2f\n", argv[0], task, calls, t);
|
||||
return -2;
|
||||
} else {
|
||||
fprintf (stdout, "%s : Task = %d Res = %e Count = %d T = %.2f\n", argv[0], task, integral, calls, t);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue