From 3aeb543b68ec3f798737b8e77985c8fd640d1108 Mon Sep 17 00:00:00 2001 From: Nazar Sendetskyi Date: Tue, 14 Jun 2022 07:44:16 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20'd?= =?UTF-8?q?u4'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du4 | 140 ------------------------------------------------------------ 1 file changed, 140 deletions(-) delete mode 100644 du4 diff --git a/du4 b/du4 deleted file mode 100644 index dcba597..0000000 --- a/du4 +++ /dev/null @@ -1,140 +0,0 @@ -#include -#include -#include -#include -#include - -struct priklad//vytvorenie štruktúry, typu, v ktorom existujú iné typy -{ - double one; - char znak; - double two; - double sum; -}; - -int sort(struct priklad prik[20]); -void printAll(struct priklad prik[20], int i); - -int main(){ - -struct priklad prik[20]; -int i = sort(prik); - -printAll(prik,i); - - return 0; -} -void printAll(struct priklad prik[20], int i){ - for (size_t j = 0; j < i; j++) -{ -if( prik[j].one == 0 && prik[j].two == 0 &&prik[j].sum == 0){ - printf("CHYBA\n"); - continue; -} - if(prik[j].znak == '+'){ - // printf("%f", prik[j].one + prik[j].two); - if (round((prik[j].one + prik[j].two)*100)/100 == prik[j].sum)// round-zaokrúhli číslo - { - printf("OK\n"); - } else - { - printf("ZLE\n"); - } - - } - if(prik[j].znak == '-'){ - if (round((prik[j].one - prik[j].two)*100)/100 == prik[j].sum) - { - printf("OK\n"); - } else - { - printf("ZLE\n"); - } - - } - if(prik[j].znak == '*'){ - if (round(prik[j].one * prik[j].two * 100) / 100 == prik[j].sum) - { - printf("OK\n"); - } else - { - printf("ZLE\n"); - } - - } - if(prik[j].znak == '/'){ - if (round(prik[j].one / prik[j].two * 100) / 100 == prik[j].sum) - { - printf("OK\n"); - } else - { - printf("ZLE\n"); - } - - } - -} -} - -int sort(struct priklad prik[20]){ -int i = 0; - while (1) - { - char step_line[30]; - char step_one[5]; - memset(step_one,' ',5);//vyplnenie štandardnými hodnotami poľa - char step_two[10]; - memset(step_two,' ',10); - char step_sum[10]; - memset(step_sum,' ',10); - char* r = fgets(step_line,30,stdin); //číta koncový znak - if (r == NULL){ - break; - } - int k = 0; - while (step_line[k] != ' ') - { - step_one[k] = step_line[k]; - k++; - } - k++; - prik[i].znak = step_line[k]; - k = k+2; - int j = 0; - while (step_line[k]!= ' ') - { - step_two[j] = step_line[k]; - k++; - j++; - } - - - k = k+3; - int p = 0; - while (k