Изменил(а) на 'du4/program.c'

This commit is contained in:
Yaroslav Orlianskyi 2022-03-30 20:46:14 +00:00
parent 6717968d1e
commit bd48c9ea21

View File

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