Обновить cv3/program.c
This commit is contained in:
		
							parent
							
								
									8c3c003af9
								
							
						
					
					
						commit
						f71ad133b9
					
				| @ -1,3 +1,4 @@ | ||||
| #include <ctype.h> | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| @ -46,13 +47,14 @@ int main() { | ||||
|     while (fgets(bufer, sizeof(bufer), stdin) != NULL) { | ||||
|         char* konec; | ||||
|         double chislo = strtod(bufer, &konec); | ||||
|         if (chislo == 0 && strcmp(bufer, "0\n") != 0) { | ||||
|             printf("bad input\n"); | ||||
|             exit(1); | ||||
|         } | ||||
|         if (*konec == '\n' && *bufer != '\n' && *bufer != ' ') { | ||||
|             if (konec - bufer == 1) { | ||||
|                 printf("bad input\n"); | ||||
|                 exit(1); | ||||
|             } | ||||
|             push(&stek, chislo); | ||||
|         } else if (strcmp(konec, "+\n") == 0) { | ||||
| 
 | ||||
|             if (isEmpty(&stek)) { | ||||
|                 printf("no input\n"); | ||||
|                 exit(1); | ||||
| @ -106,6 +108,9 @@ int main() { | ||||
|                 exit(1); | ||||
|             } | ||||
|             push(&stek, a / b); | ||||
|         } else if (isalpha(konec[-1])) { | ||||
|             printf("bad input\n"); | ||||
|             exit(1); | ||||
|         } else { | ||||
|             printf("bad input\n"); | ||||
|             exit(1); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user