Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- double calka(float);
- double metoda_Gaussa(double, double, double*, double*, double(float));
- void main(void)
- {
- double xx[10] =
- { 0.2955242247147529,
- 0.2955242247147529,
- 0.2692667193099963,
- 0.2692667193099963,
- 0.2190863625159820,
- 0.2190863625159820,
- 0.1494513491505806,
- 0.1494513491505806,
- 0.0666713443086881,
- 0.0666713443086881
- };
- double xy[10] =
- { -0.1488743389816312,
- 0.1488743389816312,
- -0.4333953941292472,
- 0.4333953941292472,
- -0.6794095682990244,
- 0.6794095682990244,
- -0.8650633666889845,
- 0.8650633666889845,
- -0.9739065285171717,
- 0.9739065285171717
- };
- printf("Wynik: %f\n", metoda_Gaussa(1, 2, xx, xy, calka));
- }
- double calka(float x)
- {
- return 1/log(x+1);
- }
- double metoda_Gaussa(double poczatek, double koniec, double *xx, double *xy, double wzor(float))
- {
- double out = 0, srednia = (koniec - poczatek) / 2;
- int i=0;
- for (i; i<10;){
- out += xx[i] * wzor(((poczatek+koniec)/2)+ srednia * xy[i]);
- i++;
- }
- return out*srednia;
- }
Add Comment
Please, Sign In to add comment