Update cv7/program.c
This commit is contained in:
		
							parent
							
								
									bf7202663e
								
							
						
					
					
						commit
						64bfb1ea96
					
				| @ -4,6 +4,7 @@ | |||||||
| #include <assert.h> | #include <assert.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| #define SIZE 200 | #define SIZE 200 | ||||||
| 
 | 
 | ||||||
| struct tree | struct tree | ||||||
| @ -11,6 +12,7 @@ struct tree | |||||||
| 
 | 
 | ||||||
|   char value[SIZE]; |   char value[SIZE]; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|   struct tree *left, *right; |   struct tree *left, *right; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -20,7 +22,6 @@ struct tree* read_tree() | |||||||
|     memset(buffer,0,SIZE); |     memset(buffer,0,SIZE); | ||||||
|     char* r = fgets(buffer,SIZE,stdin);     |     char* r = fgets(buffer,SIZE,stdin);     | ||||||
|      |      | ||||||
|    |  | ||||||
|     assert(r); |     assert(r); | ||||||
| 
 | 
 | ||||||
|     if(buffer[0]=='\n') |     if(buffer[0]=='\n') | ||||||
| @ -33,9 +34,7 @@ struct tree* read_tree() | |||||||
| 
 | 
 | ||||||
|     if(node->value[0]!='*') |     if(node->value[0]!='*') | ||||||
|     {    |     {    | ||||||
|         |  | ||||||
|         node->left=read_tree(node->left);     |         node->left=read_tree(node->left);     | ||||||
|   |  | ||||||
|         node->right=read_tree(node->right); |         node->right=read_tree(node->right); | ||||||
|     } |     } | ||||||
|     return node; |     return node; | ||||||
| @ -46,7 +45,6 @@ void print_tree(struct tree* tree,int offset){ | |||||||
|     for (int i = 0; i < offset; i++){ |     for (int i = 0; i < offset; i++){ | ||||||
|         printf("."); |         printf("."); | ||||||
|     }     |     }     | ||||||
| 
 |  | ||||||
|     if(tree) |     if(tree) | ||||||
|         printf("%s",tree->value); |         printf("%s",tree->value); | ||||||
|     if (tree->left){ |     if (tree->left){ | ||||||
| @ -83,14 +81,19 @@ int main(void) | |||||||
|         printf("%s",p->value); |         printf("%s",p->value); | ||||||
|         if(p->value[0]=='*') |         if(p->value[0]=='*') | ||||||
|             break;                 |             break;                 | ||||||
|         do |  | ||||||
|         { |  | ||||||
|         t=fgetc(stdin); |         t=fgetc(stdin); | ||||||
|         if(t=='a') |         if(t=='a') | ||||||
|             {p=p->left; break;} |         { | ||||||
|             if(t=='n') |             p=p->left; break; | ||||||
|             {p=p->right; break;} |         } | ||||||
|         }while(1); |         else if(t=='n') | ||||||
|  |         { | ||||||
|  |             p=p->right; break; | ||||||
|  |         } | ||||||
|  |         else  | ||||||
|  |         { | ||||||
|  |             printf("Nerozumiem\n"); | ||||||
|  |         }    | ||||||
|          |          | ||||||
|     }while(1); |     }while(1); | ||||||
|   |   | ||||||
| @ -100,3 +103,5 @@ int main(void) | |||||||
|   |   | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user