6
This commit is contained in:
parent
6d18b78144
commit
5b9d8d433b
@ -61,6 +61,7 @@ int main() {
|
||||
char *pend;
|
||||
stack_top = -1;
|
||||
bool first_output = true;
|
||||
bool operation_successful = true;
|
||||
|
||||
while (fgets(arr, 50, stdin)) {
|
||||
if (arr[0] == '\n' || arr[0] == EOF) {
|
||||
@ -75,6 +76,7 @@ int main() {
|
||||
}
|
||||
printf("%.2f", number);
|
||||
first_output = false;
|
||||
operation_successful = true;
|
||||
}
|
||||
else if (is_operation(arr)) {
|
||||
if (stack_top < 1) {
|
||||
@ -83,6 +85,7 @@ int main() {
|
||||
}
|
||||
printf("no input");
|
||||
first_output = false;
|
||||
operation_successful = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -96,6 +99,7 @@ int main() {
|
||||
}
|
||||
printf("%.2f", result);
|
||||
first_output = false;
|
||||
operation_successful = true;
|
||||
}
|
||||
else {
|
||||
if (!first_output) {
|
||||
@ -103,16 +107,17 @@ int main() {
|
||||
}
|
||||
printf("no input");
|
||||
first_output = false;
|
||||
operation_successful = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (stack_top == 0) {
|
||||
if (operation_successful && stack_top == 0) {
|
||||
if (!first_output) {
|
||||
printf(" ");
|
||||
}
|
||||
printf("%.2f", pop());
|
||||
} else {
|
||||
} else if (!operation_successful) {
|
||||
if (!first_output) {
|
||||
printf(" ");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user