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