Update cv7/program.c
This commit is contained in:
parent
155f61e5e8
commit
39fde4afb0
@ -21,23 +21,22 @@ struct tree* read_tree()
|
|||||||
char buffer[SIZE];
|
char buffer[SIZE];
|
||||||
memset(buffer,0,SIZE);
|
memset(buffer,0,SIZE);
|
||||||
char* r = fgets(buffer,SIZE,stdin);
|
char* r = fgets(buffer,SIZE,stdin);
|
||||||
|
|
||||||
assert(r);
|
assert(r);
|
||||||
struct tree* node = (struct tree*)calloc(1,sizeof(struct tree));
|
struct tree* node = (struct tree*)calloc(1,sizeof(struct tree));
|
||||||
memcpy(node->value,buffer,SIZE);
|
memcpy(node->value,buffer,SIZE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
node->left=NULL;
|
node->left=NULL;
|
||||||
node->right=NULL;
|
node->right=NULL;
|
||||||
|
|
||||||
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;
|
||||||
@ -67,8 +66,8 @@ int main(void)
|
|||||||
|
|
||||||
tr=read_tree();
|
tr=read_tree();
|
||||||
|
|
||||||
printf("\nExpert z bufetu to vie.");
|
printf("Expert z bufetu to vie.\n");
|
||||||
printf("\nPozna 2 druhov ovocia a zeleniny.");
|
printf("Pozna 2 druhov ovocia a zeleniny.\n");
|
||||||
|
|
||||||
struct tree *p=tr;
|
struct tree *p=tr;
|
||||||
do
|
do
|
||||||
@ -76,7 +75,7 @@ int main(void)
|
|||||||
printf("%s",p->value);
|
printf("%s",p->value);
|
||||||
if(p->value[0]=='*')
|
if(p->value[0]=='*')
|
||||||
break;
|
break;
|
||||||
printf("\nOdpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.");
|
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
||||||
char t=fgetc(stdin);
|
char t=fgetc(stdin);
|
||||||
if(t=='a')
|
if(t=='a')
|
||||||
p=p->left;
|
p=p->left;
|
||||||
@ -89,10 +88,10 @@ int main(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printf("Koniec");
|
printf("Koniec");
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user