Обновить du2/program.c
This commit is contained in:
parent
a95a2e3612
commit
345841f302
@ -3,10 +3,10 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define LINE_SIZE 100
|
||||
#define LINE_SIZE 100 //maximalna veľkosť čiary
|
||||
|
||||
int read_double(double *value, int coef_index) {
|
||||
char line[LINE_SIZE];
|
||||
char line[LINE_SIZE]; //deklaruje pole na uloženie reťazca
|
||||
|
||||
if (fgets(line, LINE_SIZE, stdin) == NULL) {
|
||||
return 0;
|
||||
@ -20,8 +20,8 @@ int read_double(double *value, int coef_index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *endptr;
|
||||
*value = strtod(line, &endptr);
|
||||
char *endptr; // smernik na hľadanie konca reťazca pri prevode na číslo
|
||||
*value = strtod(line, &endptr); // Prevod reťazca na dvojité číslo
|
||||
|
||||
|
||||
if (endptr == line || *endptr != '\0') {
|
||||
@ -39,13 +39,13 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
double coef;
|
||||
double result = 0;
|
||||
int coef_count = 0;
|
||||
double coef; //uloženie koeficientu polynómu
|
||||
double result = 0; // uloženie výsledku
|
||||
int coef_count = 0; //Počítadlo počtu zadaných koeficientov
|
||||
|
||||
while (1) {
|
||||
while (1) { //Nekonečný cyklus na zadávanie koeficientov
|
||||
coef_count++;
|
||||
int status = read_double(&coef, coef_count);
|
||||
int status = read_double(&coef, coef_count); //Číta koeficient
|
||||
|
||||
if (status == -1) {
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user