2024-01-22 14:41:15 +01:00
|
|
|
//
|
|
|
|
// Created by bruno on 1/15/24.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "array.h"
|
|
|
|
#include "stdio.h"
|
2024-01-22 15:39:50 +01:00
|
|
|
#include "stdlib.h"
|
|
|
|
#include "time.h"
|
2024-02-12 14:35:40 +01:00
|
|
|
#include "myRand.h"
|
2024-01-22 14:41:15 +01:00
|
|
|
|
|
|
|
int arraydaco() {
|
|
|
|
int pole[10];
|
|
|
|
int i;
|
|
|
|
float priemer = 0;
|
2024-01-22 15:39:50 +01:00
|
|
|
char manual;
|
|
|
|
printf("Manuálne (y/n):");
|
|
|
|
scanf("%c", &manual);
|
|
|
|
if (manual == 'y') {
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
printf("zadaj %d. prvok poľa: ", i);
|
|
|
|
scanf("%d", &pole[i]);
|
|
|
|
}
|
|
|
|
putchar('\n');
|
|
|
|
} else{
|
|
|
|
srand(time(NULL));
|
|
|
|
int od;
|
|
|
|
int po;
|
|
|
|
printf("Od:");
|
|
|
|
scanf("%d", &od);
|
|
|
|
printf("Po:");
|
|
|
|
scanf("%d", &po);
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++){
|
|
|
|
pole[i] = myrand(od, po);
|
|
|
|
}
|
2024-01-22 14:41:15 +01:00
|
|
|
}
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
printf("%d. prvok poľa je %d.\n", i, pole[i]);
|
|
|
|
}
|
|
|
|
int max = pole[0];
|
2024-01-22 15:06:18 +01:00
|
|
|
int min = pole[0];
|
2024-01-22 14:41:15 +01:00
|
|
|
int sucet = pole[0];
|
2024-01-22 15:39:50 +01:00
|
|
|
int parne = 0;
|
|
|
|
int neparne = 0;
|
2024-01-22 15:06:18 +01:00
|
|
|
for (i = 1; i < 10; i++) {
|
2024-01-22 14:41:15 +01:00
|
|
|
sucet += pole[i];
|
2024-01-22 15:06:18 +01:00
|
|
|
if (pole[i] > max) {
|
2024-01-22 14:41:15 +01:00
|
|
|
max = pole[i];
|
|
|
|
}
|
2024-01-22 15:06:18 +01:00
|
|
|
if (pole[i] < min) {
|
|
|
|
min = pole[i];
|
|
|
|
}
|
2024-02-12 14:35:40 +01:00
|
|
|
}
|
|
|
|
for (int j = 0; j < 10; ++j) {
|
|
|
|
if (pole[j] % 2){
|
2024-01-22 15:39:50 +01:00
|
|
|
neparne++;
|
2024-01-22 15:42:14 +01:00
|
|
|
} else{
|
|
|
|
parne++;
|
2024-01-22 15:39:50 +01:00
|
|
|
}
|
2024-01-22 14:41:15 +01:00
|
|
|
}
|
|
|
|
priemer = sucet / 10.0;
|
2024-01-22 15:39:50 +01:00
|
|
|
printf("\nSúčet je %d, maximum je %d, minimum je %d, párnych je %d, nepárnych je %d a priemer je %f.\n", sucet, max, min, parne, neparne, priemer);
|
2024-01-22 14:41:15 +01:00
|
|
|
return 0;
|
|
|
|
}
|