du3 - 3
This commit is contained in:
parent
bbc798be03
commit
15e6ed87dc
@ -35,7 +35,7 @@ float pop_stack(struct stack *s) {
|
||||
void print_stack(struct stack *s) {
|
||||
for (int i = 0; i < s->size; i++) {
|
||||
if (i > 0) printf(" ");
|
||||
printf("%g", s->values[i]);
|
||||
printf("%.2f ", s->values[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
@ -56,9 +56,12 @@ int main(void) {
|
||||
memset(&s, 0, sizeof(struct stack));
|
||||
|
||||
char line[LINESIZE];
|
||||
int had_input = 0;
|
||||
|
||||
while (fgets(line, sizeof(line), stdin)) {
|
||||
line[strcspn(line, "\n")] = '\0';
|
||||
|
||||
had_input = 1;
|
||||
line[strcspn(line, "\n")] = '\0';
|
||||
|
||||
//preskocit prazdny riadok
|
||||
if (strlen(line) == 0)
|
||||
@ -100,5 +103,9 @@ int main(void) {
|
||||
print_stack(&s);
|
||||
}
|
||||
|
||||
if (had_input) {
|
||||
printf("no input\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user