Обновить a1/program.c
This commit is contained in:
		
							parent
							
								
									5aab1928a4
								
							
						
					
					
						commit
						9fc60b89cf
					
				
							
								
								
									
										12
									
								
								a1/program.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								a1/program.c
									
									
									
									
									
								
							| @ -11,11 +11,14 @@ typedef struct { | ||||
| int main() { | ||||
|     char line[MAX_LEN + 1]; | ||||
|     StackItem stack[MAX_LEN]; | ||||
|     int top = -1;  | ||||
|     int top = -1; | ||||
| 
 | ||||
|     printf("Enter the code: "); | ||||
|     fgets(line, sizeof(line), stdin); | ||||
| 
 | ||||
|     printf("Read: %s", line); | ||||
|     // Odstránime nový riadok na konci vstupu, ak existuje
 | ||||
|     line[strcspn(line, "\n")] = 0; | ||||
|     printf("Read: %s\n", line); | ||||
| 
 | ||||
|     for (int i = 0; line[i] != '\0'; i++) { | ||||
|         char ch = line[i]; | ||||
| @ -25,10 +28,9 @@ int main() { | ||||
|                 stack[++top].bracket = ch; | ||||
|                 stack[top].position = i; | ||||
|             } | ||||
|         } | ||||
|         else if (ch == ')' || ch == '}' || ch == ']' || ch == '>') { | ||||
|         } else if (ch == ')' || ch == '}' || ch == ']' || ch == '>') { | ||||
|             if (top == -1) { | ||||
|      | ||||
|                 printf("Unexpected closing bracket %c in %d\n", ch, i); | ||||
|                 return 0; | ||||
|             } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user