Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <stdio.h>
- int main()
- {
- float **x, *b;
- int n, i, j;
- printf("input n: "); scanf("%d", &n);
- x = (float**) malloc(sizeof(float*) * n);
- b = (float*) malloc(sizeof(float*) * n);
- for (i = 0; i < n; i++)
- *(x+i) = (float*) malloc(sizeof(float) * n);
- printf("input array: ");
- for (i = 0; i < n; i++)
- for (j = 0; j < n; j++)
- scanf("%f", *(x+i)+j);
- for (i = 0; i < n; i++)
- {
- float ser = 0.0;
- for (j = 0; j < n; j++)
- ser += *(*(x+i)+j);
- *(b+i) = ser / n;
- }
- for (i = 0; i < n; i++)
- printf("%f ", *(b+i));
- for (i = 0; i < n; i++)
- free(*(x+i));
- free(x);
- free(b);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment