#include <stdio.h>
#define TABSIZE 5
double sum_tab(double tab[], size_t len);
void print_tab(double tab[], size_t len);
int main(void) {
double X = 832.232323;
double tab_1[TABSIZE] = {45, 8.324, 9999, 9234932, 843.32};
double tab_2[TABSIZE];
double suma = sum_tab(tab_1, TABSIZE);
for(size_t i=0;i<TABSIZE;++i) { tab_2[i] = tab_1[i]/suma; }
for(size_t i=0;i<TABSIZE;++i) { tab_2[i] = tab_2[i] * X; }
print_tab(tab_1, TABSIZE);
print_tab(tab_2, TABSIZE);
printf("X = %5.5f\nsuma tablicy = %5.5f\n", X
, sum_tab
(tab_2
, TABSIZE
)); return 0;
}
double sum_tab(double tab[], size_t len) {
double sum = 0;
for(size_t i=0;i<len;++i) { sum += tab[i]; }
return sum;
}
void print_tab(double tab[], size_t len) {
for(size_t i=0;i<len;++i) {
if((i
%5) == 4) { printf("\n"); } }
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgojZGVmaW5lIFRBQlNJWkUgNQoKZG91YmxlIHN1bV90YWIoZG91YmxlIHRhYltdLCBzaXplX3QgbGVuKTsKdm9pZCBwcmludF90YWIoZG91YmxlIHRhYltdLCBzaXplX3QgbGVuKTsKCmludCBtYWluKHZvaWQpIHsKCWRvdWJsZSBYID0gODMyLjIzMjMyMzsKCWRvdWJsZSB0YWJfMVtUQUJTSVpFXSA9IHs0NSwgOC4zMjQsIDk5OTksIDkyMzQ5MzIsIDg0My4zMn07Cglkb3VibGUgdGFiXzJbVEFCU0laRV07CgkKCWRvdWJsZSBzdW1hID0gc3VtX3RhYih0YWJfMSwgVEFCU0laRSk7CgkKCWZvcihzaXplX3QgaT0wO2k8VEFCU0laRTsrK2kpIHsgdGFiXzJbaV0gPSB0YWJfMVtpXS9zdW1hOyB9Cglmb3Ioc2l6ZV90IGk9MDtpPFRBQlNJWkU7KytpKSB7CXRhYl8yW2ldID0gdGFiXzJbaV0gKiBYOyB9CgkKCXB1dHMoInRhYl8xIik7CglwcmludF90YWIodGFiXzEsIFRBQlNJW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