6 #define VELIKOST_BLOKU 50
11 int generuj_data(
char *nazev,
int max,
long pocet);
12 int precti_data(
char *nazev);
13 double vel_vektor(
double *v);
14 int uprav_data(
char *nazev);
19 generuj_data(
"data.dat", 100, 123);
20 precti_data(
"data.dat");
21 uprav_data(
"data.dat");
22 printf(
"\nNova data: \n");
23 precti_data(
"data.dat");
31 int generuj_data(
char *nazev,
int max,
long pocet)
34 double data[VELIKOST_BLOKU];
39 f = fopen(nazev,
"wb");
44 srand((
unsigned) time(NULL));
47 for (i = 0; i < pocet / VELIKOST_BLOKU; i++) {
50 for (j = 0; j < VELIKOST_BLOKU; j++) {
51 data[j] = (rand() % (max * PRESNOST)) / (double) PRESNOST;
55 zapsano = (unsigned) fwrite(data,
sizeof(
double), VELIKOST_BLOKU, f);
58 if (zapsano != VELIKOST_BLOKU) {
65 for (j = 0; j < pocet % VELIKOST_BLOKU; j++) {
66 data[j] = (rand() % (max * PRESNOST)) / (double) PRESNOST;
70 zapsano = (unsigned) fwrite(data,
sizeof(
double), pocet % VELIKOST_BLOKU, f);
73 if (zapsano != pocet % VELIKOST_BLOKU) {
85 int precti_data(
char *nazev)
88 double data[VELIKOST_BLOKU];
90 unsigned int precteno;
93 f = fopen(nazev,
"rb");
100 precteno = (unsigned) fread(data,
sizeof(
double), VELIKOST_BLOKU, f);
103 for (i = 0; i < precteno; i++) {
104 printf(
"%g ", data[i]);
107 }
while (precteno == VELIKOST_BLOKU);
110 if (EOF == fclose(f))
116 double vel_vektor(
double *v)
120 for (i = 0; i < DIMENZE; i++)
125 int uprav_data(
char *nazev)