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 <stdio.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
int c[2];
|
int c[999];
|
||||||
int a, i = 0;
|
int a, i = 0;
|
||||||
int vysledok;
|
int vysledok;
|
||||||
char riadok[999];
|
char riadok[999];
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
bool first = true;
|
char need;
|
||||||
bool second = false;
|
|
||||||
while(1){
|
while(1){
|
||||||
a++;
|
a++;
|
||||||
char* r = fgets(riadok,999,stdin);
|
char* r = fgets(riadok,999,stdin);
|
||||||
@ -17,38 +15,34 @@ int main(){
|
|||||||
}else if(*r == ' ')
|
}else if(*r == ' ')
|
||||||
continue;
|
continue;
|
||||||
else if(*r == '+'){
|
else if(*r == '+'){
|
||||||
first = true;
|
need = *r;
|
||||||
second = true;;
|
|
||||||
continue;
|
continue;
|
||||||
}else if(*r == '-'){
|
}else if(*r == '-'){
|
||||||
first = false;
|
need = *r;
|
||||||
second = false;
|
|
||||||
continue;
|
continue;
|
||||||
}else if(*r == '/'){
|
}else if(*r == '/'){
|
||||||
first = true;
|
need = *r;
|
||||||
second = false;
|
|
||||||
continue;
|
continue;
|
||||||
}else if(*r == '*'){
|
}else if(*r == '*'){
|
||||||
first = false;
|
need = *r;
|
||||||
second = true;
|
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
float v = strtod(riadok,&endptr);
|
int v = strtod(riadok,&endptr);
|
||||||
c[i++] = v;
|
c[i++] = v;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(first == true && second == true)
|
if(need == '+')
|
||||||
vysledok = c[0] + c[1];
|
vysledok = c[0] + c[1];
|
||||||
else if(first == false && second == false)
|
else if(need == '-')
|
||||||
vysledok = c[0] - c[1];
|
vysledok = c[0] - c[1];
|
||||||
else if(first == true && second == false)
|
else if(need == '/')
|
||||||
vysledok = c[0] / c[1];
|
vysledok = c[0] / c[1];
|
||||||
else if(first == false && second == true)
|
else if(need == '*')
|
||||||
vysledok = c[0] * c[1];
|
vysledok = c[0] * c[1];
|
||||||
if(vysledok == c[2])
|
if(vysledok == c[i])
|
||||||
printf("OK\n");
|
printf("OK\n");
|
||||||
else
|
else
|
||||||
printf("ZLE\n");
|
printf("ZLE\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user