buffet
This commit is contained in:
parent
9612fdbc1b
commit
3b9cbe3f4c
@ -18,15 +18,9 @@ struct tree* read_tree(){
|
|||||||
buffer[x-1]='\0';
|
buffer[x-1]='\0';
|
||||||
|
|
||||||
assert(r);
|
assert(r);
|
||||||
if(buffer[0] == '\0'){
|
if(buffer[0] != '\0'){
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct tree* node = calloc(1,sizeof(struct tree));
|
struct tree* node = calloc(1,sizeof(struct tree));
|
||||||
/*if(buffer[0] == '\0'){
|
|
||||||
return node;
|
|
||||||
}*/
|
|
||||||
memcpy(node->value, buffer,50);
|
memcpy(node->value, buffer,50);
|
||||||
if(buffer[0] != '*'){
|
if(buffer[0] != '*'){
|
||||||
if(node->left == NULL){
|
if(node->left == NULL){
|
||||||
@ -38,29 +32,25 @@ struct tree* read_tree(){
|
|||||||
}
|
}
|
||||||
//if(node->left != NULL && node->right != NULL){
|
//if(node->left != NULL && node->right != NULL){
|
||||||
return node;
|
return node;
|
||||||
|
}
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
struct tree* search(struct tree* this){
|
struct tree* search(struct tree* this){
|
||||||
|
|
||||||
/*char question[30] = "Je to ovocie alebo zelenina";
|
|
||||||
if(strcmp(this->value,question) == 0){
|
|
||||||
printf("%s\n", this->value);
|
|
||||||
this = search(this);
|
|
||||||
}*/
|
|
||||||
char c = getchar();
|
char c = getchar();
|
||||||
/*char buffer[50];
|
/*char buffer[50];
|
||||||
memset(buffer, 0, 50);
|
memset(buffer, 0, 50);
|
||||||
int x = strlen(buffer);
|
int x = strlen(buffer);
|
||||||
buffer[x-1]='\0';
|
buffer[x-1]='\0';
|
||||||
memcpy(buffer, this->value, 50); */
|
memcpy(buffer, this->value, 50); */
|
||||||
if(this != 0){
|
if(this != NULL){
|
||||||
if(c == 'a'){
|
if(c == 'a'){
|
||||||
printf("%s\n", this->value);
|
printf("%s\n", this->value);
|
||||||
this = search(this->left);
|
this->left = search(this->left);
|
||||||
}
|
}
|
||||||
else if(c == 'n'){
|
else if(c == 'n'){
|
||||||
printf("%s\n", this->value);
|
printf("%s\n", this->value);
|
||||||
this = search(this->right);
|
this->right = search(this->right);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user