2020-11-24 19:08:55 +00:00
|
|
|
#include <stdio.h>
|
2020-11-24 19:18:19 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#define MAX 20
|
2020-11-24 21:16:29 +00:00
|
|
|
|
2020-11-24 21:09:44 +00:00
|
|
|
struct node {
|
|
|
|
int data;
|
|
|
|
struct node* left;
|
|
|
|
struct node* right;
|
|
|
|
};
|
|
|
|
void preorderTraversal(struct node* root) {
|
|
|
|
if (root == NULL) return;
|
|
|
|
printf("%d", root->data);
|
|
|
|
preorderTraversal(root->left);
|
|
|
|
preorderTraversal(root->right);
|
|
|
|
}
|
2020-11-24 19:08:55 +00:00
|
|
|
int main() {
|
2020-11-24 19:18:19 +00:00
|
|
|
//int l = i * 2 + 1;
|
|
|
|
//int r = i * 2 + 2;
|
2020-11-24 21:09:44 +00:00
|
|
|
struct node* root;
|
2020-11-24 19:57:21 +00:00
|
|
|
int i,n;
|
2020-11-24 19:18:19 +00:00
|
|
|
int *a = calloc(MAX, sizeof(int));
|
2020-11-24 19:50:11 +00:00
|
|
|
for (i = 0; i < MAX; i++) {
|
2020-11-24 21:16:29 +00:00
|
|
|
scanf("%d", root->data);
|
2020-11-24 19:59:33 +00:00
|
|
|
if(a[i]!=0){
|
|
|
|
n++;
|
|
|
|
}
|
2020-11-24 19:50:11 +00:00
|
|
|
}
|
2020-11-24 21:09:44 +00:00
|
|
|
|
2020-11-24 19:21:03 +00:00
|
|
|
printf("Je to taka kopa:\n");
|
2020-11-24 21:09:44 +00:00
|
|
|
/*for (i = 0; i < n; i++) {
|
2020-11-24 20:28:41 +00:00
|
|
|
printf("%d\n", a[i]);
|
2020-11-24 21:09:44 +00:00
|
|
|
if(a[i+1]!=0){
|
2020-11-24 20:34:48 +00:00
|
|
|
}
|
2020-11-24 21:09:44 +00:00
|
|
|
}*/
|
|
|
|
preorderTraversal(root);
|
2020-11-24 19:08:55 +00:00
|
|
|
|
|
|
|
return 0;
|
2020-11-24 20:30:30 +00:00
|
|
|
}
|