Обновить cv3/program.c
This commit is contained in:
		
							parent
							
								
									863f360310
								
							
						
					
					
						commit
						85f66425f9
					
				| @ -51,7 +51,7 @@ int main() { | ||||
| 
 | ||||
|         if (c == '\n' && *bufer != '\n' && *bufer != ' ') { | ||||
|             push(&stek, chislo); | ||||
|         } else if (c == '+') { | ||||
|         } else if (c == '+' || c == '-' || c == '*' || c == '/') { | ||||
|             if (isEmpty(&stek)) { | ||||
|                 printf("no input\n"); | ||||
|                 exit(1); | ||||
| @ -62,47 +62,19 @@ int main() { | ||||
|                 exit(1); | ||||
|             } | ||||
|             double a = pop(&stek); | ||||
|             push(&stek, a + b); | ||||
|         } else if (c == '-') { | ||||
|             if (isEmpty(&stek)) { | ||||
|                 printf("no input\n"); | ||||
|                 exit(1); | ||||
|             if (c == '+') { | ||||
|                 push(&stek, a + b); | ||||
|             } else if (c == '-') { | ||||
|                 push(&stek, a - b); | ||||
|             } else if (c == '*') { | ||||
|                 push(&stek, a * b); | ||||
|             } else if (c == '/') { | ||||
|                 if (b == 0) { | ||||
|                     printf("division by zero\n"); | ||||
|                     return 0; | ||||
|                 } | ||||
|                 push(&stek, a / b); | ||||
|             } | ||||
|             double b = pop(&stek); | ||||
|             if (isEmpty(&stek)) { | ||||
|                 printf("no input\n"); | ||||
|                 exit(1); | ||||
|             } | ||||
|             double a = pop(&stek); | ||||
|             push(&stek, a - b); | ||||
|         } else if (c == '*') { | ||||
|             if (isEmpty(&stek)) { | ||||
|                 printf("no input\n"); | ||||
|                 exit(1); | ||||
|             } | ||||
|             double b = pop(&stek); | ||||
|             if (isEmpty(&stek)) { | ||||
|                 printf("no input\n"); | ||||
|                 exit(1); | ||||
|             } | ||||
|             double a = pop(&stek); | ||||
|             push(&stek, a * b); | ||||
|         } else if (c == '/') { | ||||
|             if (isEmpty(&stek)) { | ||||
|                 printf("no input\n"); | ||||
|                 exit(1); | ||||
|             } | ||||
|             double b = pop(&stek); | ||||
|             if (isEmpty(&stek)) { | ||||
|                 printf("no input\n"); | ||||
|                 exit(1); | ||||
|             } | ||||
|             double a = pop(&stek); | ||||
|             if (b == 0) { | ||||
|                 printf("division by zero\n"); | ||||
|                 return 0; | ||||
|             } | ||||
|             push(&stek, a / b); | ||||
|         } else if (isalpha(c)) { | ||||
|             printf("bad input\n"); | ||||
|             return 0; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user