Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stddef.h>
- #include <stdalign.h>
- struct Chunk {
- float *speeds;
- };
- #define N 1024
- #define M 512
- int main(void)
- {
- int jj, kk;
- int nx;
- static struct Chunk c[N];
- float partial;
- float out[N];
- float *fp;
- for (jj = 0; jj < N; jj++) {
- c[jj].speeds = malloc(M * sizeof(float));
- for (kk = 0; kk < M; kk++) {
- if (scanf("%f", &(c[jj].speeds[kk])) < 1)
- return -1;
- }
- }
- if (scanf("%d", &nx) < 1)
- return -1;
- for (jj = 0; jj < nx; jj++) {
- partial = 0.0f;
- fp = c[jj].speeds;
- for (kk = 0; kk < M; kk++)
- partial += fp[kk];
- out[jj] = partial;
- }
- for (jj = 0; jj < N; jj++) {
- printf("%g\n", out[jj]);
- free(c[jj].speeds);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement