diff --git a/du3/program b/du3/program index 0d73c7e..084775c 100755 Binary files a/du3/program and b/du3/program differ diff --git a/du3/program.c b/du3/program.c index 9882a7f..3215859 100644 --- a/du3/program.c +++ b/du3/program.c @@ -1,32 +1,21 @@ #include -#include -#include -#define LINE_SIZE 999 int main(){ - char riadok[LINE_SIZE]; - memset(riadok, 0,LINE_SIZE); - char* r = fgets(riadok,LINE_SIZE,stdin); - char line[LINE_SIZE]; - int len = strlen(line); - char* endptr = NULL; - char* start = line; - int num = 0; - if (r == NULL){ - exit(0); - } - int r2 = atol(line); - if (r2 == 0){ - exit(0); - } - while (start < (line + len)){ - num = strtol(start,&endptr,10); - if (num){ - printf("Nacital som %d\n",num); - start = endptr + 1; - } - else - break; + int vxod[999]; + int i = 0; + int result = 0; + while(1){ + int value = 0; + int r = scanf("%d",&value); + if(r == 1){ + vxod[i++] = value; + } + else{ + for(int a = 1; a < i; a++) + result = vxod[0] * result + vxod[a]; + printf("Vysledok je: %d.00\n", result); + break; + } } return 0; } diff --git a/du3/test b/du3/test index 6ef1c58..d371975 100755 Binary files a/du3/test and b/du3/test differ diff --git a/du3/test.c b/du3/test.c index a69198d..668b584 100644 --- a/du3/test.c +++ b/du3/test.c @@ -1,11 +1,14 @@ #include +#include +#include +#define LINE_SIZE 999 int main(){ - int c = 0; - char a = 'a'; - if(a >= 0 && a <= 255) - printf("yes\n"); - else - printf("no\n"); + char riadok[LINE_SIZE]; + memset(riadok, 0,LINE_SIZE); + char* r = fgets(riadok,LINE_SIZE,stdin); + if(r == NULL){ + exit(0); + } return 0; }