Update cv3/program.c
This commit is contained in:
		
							parent
							
								
									374ae747b0
								
							
						
					
					
						commit
						cee902690b
					
				| @ -30,14 +30,17 @@ int main() { | ||||
|         input[strcspn(input, "\n")] = 0;   | ||||
| 
 | ||||
|         if (strlen(input) == 0) { | ||||
|              | ||||
|             printf("no input\n"); | ||||
|             break; | ||||
|         } | ||||
| 
 | ||||
|         if (is_number(input)) { | ||||
|              | ||||
|             float value = atof(input); | ||||
|             push_stack(&mystack, value); | ||||
|         } else if (strlen(input) == 1 && strchr("+-*/", input[0])) { | ||||
|             | ||||
|             if (mystack.size < 2) { | ||||
|                 fprintf(stderr, "Error: Not enough values in stack.\n"); | ||||
|                 exit(EXIT_FAILURE); | ||||
| @ -93,8 +96,8 @@ float pop_stack(struct stack* stack) { | ||||
| } | ||||
| 
 | ||||
| void print_stack(struct stack* stack) { | ||||
|      | ||||
|     for (int i = 0; i < stack->size; i++) { | ||||
|          | ||||
|         printf("%.2f ", stack->values[i]); | ||||
|     } | ||||
|     printf("\n"); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user