Update du1/program.c
WIP
This commit is contained in:
parent
2247d7eead
commit
caebd6d24a
@ -1,13 +1,46 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#define LINE_SIZE 100
|
||||||
|
|
||||||
|
int vyhodnot_vstup (float *num){
|
||||||
|
//return value podla toho ci je input validny alebo nie
|
||||||
|
char vstup[LINE_SIZE];
|
||||||
|
memset (vstup, 0, LINE_SIZE);
|
||||||
|
char *citaj = fgets (vstup, LINE_SIZE, stdin);
|
||||||
|
|
||||||
|
if (citaj == NULL) return -1; //-1 ak je NULL
|
||||||
|
else if (vstup[0] == '\n') return -2; //-2 ak sa vyenteroval input
|
||||||
|
|
||||||
|
char *ukoncovaci;
|
||||||
|
float hodnota = strtof (vstup, &ukoncovaci);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
|
|
||||||
char riadok[LINE_SIZE];
|
float num = 0;
|
||||||
memset(riadok, 0,LINE_SIZE);
|
|
||||||
char* r = fgets(riadok,LINE_SIZE,stdin);
|
//prepis vstupu do premennej
|
||||||
|
int vyhodnotenie = vyhodnot_vstup(&num);
|
||||||
|
|
||||||
|
//vyhodnotenie vysledkov pomocnej funkcie
|
||||||
|
|
||||||
|
|
||||||
|
//nejak horner
|
||||||
|
|
||||||
|
|
||||||
|
//vysledok
|
||||||
|
|
||||||
|
|
||||||
|
//win
|
||||||
|
|
||||||
|
|
||||||
if (r == NULL){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user