Оновити 'cv3/program.c'
This commit is contained in:
parent
dcbdb29615
commit
b93a837ae5
@ -1,21 +1,30 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#define LENGTH 256
|
||||||
#include <ctype.h>
|
|
||||||
#define MAX_I_LINE_LENGTH 256
|
|
||||||
int main(){
|
int main(){
|
||||||
char line[MAX_I_LINE_LENGTH];
|
char line[LENGTH];
|
||||||
int cfIdx = 0;
|
int cfIdx, cf1 = 0;
|
||||||
double x, cf,result = 0;
|
double x, cf,result = 0;
|
||||||
fgets(line, 100, stdin);
|
fgets(line, 100, stdin);
|
||||||
x = strtod(line, NULL);
|
x = strtod(line, NULL);
|
||||||
|
cf1 = x;
|
||||||
|
if(cf1 == 0 && line[0] != '\n'){
|
||||||
|
printf("Nepodarilo sa nacitat zaklad x\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
while(line[0] != '\n'){
|
while(line[0] != '\n'){
|
||||||
|
cfIdx++;
|
||||||
result = result * x + cf;
|
result = result * x + cf;
|
||||||
fgets(line, 100, stdin);
|
fgets(line, 100, stdin);
|
||||||
cf = strtod(line,NULL);
|
cf = strtod(line,NULL);
|
||||||
|
cf1 = cf;
|
||||||
|
if(cf1 == 0 && line[0] != '\n'){
|
||||||
|
printf("\nNepodarilo sa nacitat polynom na %d mieste.\n", cfIdx);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("Vysledok je: %.2f\n", result);
|
printf("Vysledok je: %.2f\n", result);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user