schema
This commit is contained in:
parent
d478fb09b2
commit
d5d8deff25
@ -16,13 +16,12 @@ int main() {
|
|||||||
double result = 1;
|
double result = 1;
|
||||||
int coefficientIndex = 0;
|
int coefficientIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) {
|
if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) {
|
||||||
printf("Nepodarilo sa nacitat zaklad x\n");
|
printf("Nepodarilo sa nacitat zaklad x\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double x_base = strtod(line, NULL);
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) {
|
if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) {
|
||||||
if (line[0] == '\n') {
|
if (line[0] == '\n') {
|
||||||
@ -33,16 +32,17 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *endPtr;
|
char *endPtr;
|
||||||
double coefficient = strtod(line, &endPtr);
|
double x = strtod(line, &endPtr);
|
||||||
if (*endPtr != '\n' && *endPtr != '\0') {
|
if (*endPtr != '\n' && *endPtr != '\0') {
|
||||||
printf("Nespravny format cisla\n");
|
printf("Nespravny format cisla\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = result * x_base + coefficient;
|
result *= x;
|
||||||
coefficientIndex++;
|
coefficientIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Vysledok je: %.2f\n", result);
|
printf("Vysledok je: %.2f\n", result);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user