• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

LazySenpai Nov 24th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
2. #include <math.h>
3. #include <stdio.h>
4. #include <stdlib.h>
5. #include <unistd.h>
6. #define N 10
7.
9. double sum=0;
10. typedef struct {
11. int x;
12. int i;
13. }argument;
14.
15. int silnia(int n) {
16.     if (n == 0) return 1;
17.     if (n == 1) return 1;
18.     return n*silnia(n-1);
19. }
20.
21. void* obliczIloczyn(void* ptr)
22. {
23.     argument* arg = ptr;
24.     int dol = silnia(arg->i);
25.     double gora = pow((double)arg->x,(double)arg->i);
26.     //printf("gora: %f\n",gora);
27.     //printf("dol: %d\n",dol);
28.     double dziel = (double)gora / (double)dol;
29.     double* suma = malloc(sizeof(double));
30.     *suma = dziel;
31.
33.
34.     sum+=*suma;
35.
37.
38.     printf("suma: %f\n",*suma);
40. }
41.
42. int main()
43. {
44.     double wynik=0;
45.     double* result[N];
46.     int i;
48.     for(i=0;i<N;i++)
49.     {
50.         argument* arg= malloc(sizeof(argument));
51.         arg->x = 1;
52.         arg->i = i;