Fixing whitespace
This commit is contained in:
parent
4a00c12f43
commit
308a10b9ef
@ -3,7 +3,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#define SIZE 1000
|
#define SIZE 100
|
||||||
|
|
||||||
|
|
||||||
struct tree{
|
struct tree{
|
||||||
@ -27,7 +27,7 @@ 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);
|
||||||
if(!r){
|
if(!r) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
r[strcspn(r, "\n")] = '\0';
|
r[strcspn(r, "\n")] = '\0';
|
||||||
@ -42,6 +42,9 @@ struct tree* read_tree(){
|
|||||||
}
|
}
|
||||||
node->left = read_tree();
|
node->left = read_tree();
|
||||||
node->right = read_tree();
|
node->right = read_tree();
|
||||||
|
// Ak je nacitany riadok listovy uzol ,tak netreba robit nic
|
||||||
|
// inak rekurzivne nacitanie laveho syna
|
||||||
|
// a rekurzivne nacitanie praveho syna
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
void print_tree(struct tree* tree,int offset){
|
void print_tree(struct tree* tree,int offset){
|
||||||
@ -73,6 +76,8 @@ int main(void){
|
|||||||
|
|
||||||
struct tree* tree = read_tree();
|
struct tree* tree = read_tree();
|
||||||
char line[SIZE];
|
char line[SIZE];
|
||||||
|
|
||||||
|
|
||||||
while( fgets(line, sizeof(line), stdin)){
|
while( fgets(line, sizeof(line), stdin)){
|
||||||
line[strcspn(line, "\n")] = '\0';
|
line[strcspn(line, "\n")] = '\0';
|
||||||
if(line[0] == '\0'){
|
if(line[0] == '\0'){
|
||||||
@ -81,15 +86,15 @@ int main(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!whitespace && tree != NULL){
|
//if(!whitespace && tree != NULL){
|
||||||
printf("No whitespace after database\n");
|
//printf("No whitespace after database\n");
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
//}
|
||||||
int numOfLeaves = count_leaves(tree);
|
int numOfLeaves = count_leaves(tree);
|
||||||
char answer[SIZE];
|
char answer[SIZE];
|
||||||
printf("Expert z bufetu to vie.\n");
|
printf("Expert z bufetu to vie.\n");
|
||||||
if(tree == NULL){
|
if(!tree){
|
||||||
printf("Chybna databaza\n");
|
printf("Chybova databaza\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf("Pozna %d druhov ovocia a zeleniny.\n", numOfLeaves);
|
printf("Pozna %d druhov ovocia a zeleniny.\n", numOfLeaves);
|
||||||
@ -128,5 +133,4 @@ int main(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
destroy_tree(tree);
|
destroy_tree(tree);
|
||||||
return 0;
|
return 0;}
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user