Изменил(а) на '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 <stdbool.h>
int main(){
int c[2];
int a = 0;
int vysledok;
char riadok[999];
char *endptr = NULL;
int main ()
{
int c, vysledok, i = 0;
int b[99];
bool first = true;
bool second = false;
while(1){
char* r = fgets(riadok,999,stdin);
if(*r == '\n'){
c = getchar();
if(c <= 255 && c >= 0){
if(c == '\n'){
break;
}else if(*r == ' ')
}else if(c == ' '){
continue;
else if(*r == '+'){
}else if(c == '='){
continue;
}else if(c == '+'){
first = true;
second = true;;
second = true;
continue;
}else if(*r == '-'){
}else if(c == '-'){
first = false;
second = false;
continue;
}else if(*r == '/'){
}else if(c == '/'){
first = true;
second = false;
continue;
}else if(*r == '*'){
}else if(c == '*'){
first = false;
second = true;
continue;
}
}else{
int v = strtod(riadok,&endptr);
c[a] = v;
printf("%d, %d\n", v, c[a];
a++;
continue;
if(i == 2)
break;
c = 0;
int r = scanf("%d",&c);
b[i++] = c;
}
}
if(first == true && second == true)
vysledok = c[0] + c[1];
vysledok = b[0] + b[1];
else if(first == false && second == false)
vysledok = c[0] - c[1];
vysledok = b[0] - b[1];
else if(first == true && second == false)
vysledok = c[0] / c[1];
vysledok = b[0] / b[1];
else if(first == false && second == true)
vysledok = c[0] * c[1];
if(vysledok == c[2])
vysledok = b[0] * b[1];
if(vysledok == b[2])
printf("OK\n");
else
printf("ZLE\n");