Update cv7/program.c
This commit is contained in:
parent
67de6c8629
commit
cba7e62977
@ -4,15 +4,13 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
#define SIZE 200
|
#define SIZE 200
|
||||||
|
|
||||||
struct tree
|
struct tree
|
||||||
{
|
{
|
||||||
|
|
||||||
char value[SIZE];
|
char value[SIZE];
|
||||||
|
|
||||||
|
|
||||||
struct tree *left, *right;
|
struct tree *left, *right;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -21,14 +19,11 @@ 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;
|
||||||
|
|
||||||
@ -47,7 +42,7 @@ 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){
|
||||||
@ -71,9 +66,9 @@ int main(void)
|
|||||||
printf("Pozna 2 druhov ovocia a zeleniny.\n");
|
printf("Pozna 2 druhov ovocia a zeleniny.\n");
|
||||||
|
|
||||||
struct tree *p=tr;
|
struct tree *p=tr;
|
||||||
|
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
|
||||||
printf("%s",p->value);
|
printf("%s",p->value);
|
||||||
if(p->value[0]=='*')
|
if(p->value[0]=='*')
|
||||||
break;
|
break;
|
||||||
@ -87,10 +82,11 @@ int main(void)
|
|||||||
}while(1);
|
}while(1);
|
||||||
|
|
||||||
}while(1);
|
}while(1);
|
||||||
|
|
||||||
|
|
||||||
printf("Koniec\n");
|
printf("Koniec\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user