SAD
This commit is contained in:
parent
6f81912e02
commit
d09136c0cb
BIN
du4/program
BIN
du4/program
Binary file not shown.
@ -1,14 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int main(){
|
||||
int c[2];
|
||||
int c[999];
|
||||
int a, i = 0;
|
||||
int vysledok;
|
||||
char riadok[999];
|
||||
char *endptr = NULL;
|
||||
bool first = true;
|
||||
bool second = false;
|
||||
char need;
|
||||
while(1){
|
||||
a++;
|
||||
char* r = fgets(riadok,999,stdin);
|
||||
@ -17,36 +15,32 @@ int main(){
|
||||
}else if(*r == ' ')
|
||||
continue;
|
||||
else if(*r == '+'){
|
||||
first = true;
|
||||
second = true;;
|
||||
need = *r;
|
||||
continue;
|
||||
}else if(*r == '-'){
|
||||
first = false;
|
||||
second = false;
|
||||
need = *r;
|
||||
continue;
|
||||
}else if(*r == '/'){
|
||||
first = true;
|
||||
second = false;
|
||||
need = *r;
|
||||
continue;
|
||||
}else if(*r == '*'){
|
||||
first = false;
|
||||
second = true;
|
||||
need = *r;
|
||||
continue;
|
||||
}else{
|
||||
float v = strtod(riadok,&endptr);
|
||||
int v = strtod(riadok,&endptr);
|
||||
c[i++] = v;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(first == true && second == true)
|
||||
if(need == '+')
|
||||
vysledok = c[0] + c[1];
|
||||
else if(first == false && second == false)
|
||||
else if(need == '-')
|
||||
vysledok = c[0] - c[1];
|
||||
else if(first == true && second == false)
|
||||
else if(need == '/')
|
||||
vysledok = c[0] / c[1];
|
||||
else if(first == false && second == true)
|
||||
else if(need == '*')
|
||||
vysledok = c[0] * c[1];
|
||||
if(vysledok == c[2])
|
||||
if(vysledok == c[i])
|
||||
printf("OK\n");
|
||||
else
|
||||
printf("ZLE\n");
|
||||
|
Loading…
Reference in New Issue
Block a user