Upload files to "du2"
This commit is contained in:
parent
3b2e079603
commit
5cb08b0693
33
du2/program.c
Normal file
33
du2/program.c
Normal file
@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
double x;
|
||||
double kof;
|
||||
double result = 0.0;
|
||||
int pocet_kof = 0;
|
||||
|
||||
// Nacitanie x
|
||||
if (scanf("%lf", &x) != 1) {
|
||||
printf("Chyba: Neplatna hodnota x.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Nacitanie koeficientu a vypocet
|
||||
while (scanf("%d", &kof) == 1) {
|
||||
result = result * x + kof;
|
||||
pocet_kof++;
|
||||
}
|
||||
|
||||
// Ak nebol nacitany koeficient,vypise chybu
|
||||
if (pocet_kof == 0) {
|
||||
printf("Chyba: Nezadali ste žiadne koeficienty.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// vysledkok
|
||||
printf("Vysledok je: %.2f\n", result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user