This commit is contained in:
Yaroslav Orlianskyi 2022-03-30 22:45:48 +02:00
parent adb070e283
commit 6717968d1e
2 changed files with 57 additions and 0 deletions

BIN
du4/test Executable file

Binary file not shown.

57
du4/test.c Normal file
View File

@ -0,0 +1,57 @@
#include <stdio.h>
#include <stdbool.h>
int main ()
{
int c, vysledok, i = 0;
int b[99];
bool first = true;
bool second = false;
while(1){
c = getchar();
if(c <= 255 && c >= 0){
if(c == '\n'){
break;
}else if(c == ' '){
continue;
}else if(c == '='){
continue;
}else if(c == '+'){
first = true;
second = true;
continue;
}else if(c == '-'){
first = false;
second = false;
continue;
}else if(c == '/'){
first = true;
second = false;
continue;
}else if(c == '*'){
first = false;
second = true;
continue;
}
}else{
if(i == 2)
break;
c = 0;
int r = scanf("%d",&c);
b[i++] = c;
}
}
if(first == true && second == true)
vysledok = b[0] + b[1];
else if(first == false && second == false)
vysledok = b[0] - b[1];
else if(first == true && second == false)
vysledok = b[0] / b[1];
else if(first == false && second == true)
vysledok = b[0] * b[1];
if(vysledok == b[2])
printf("OK\n");
else
printf("ZLE\n");
return 0;
}