This commit is contained in:
Radovan Kofira 2020-11-24 22:22:38 +01:00
parent 6b98cd5c9f
commit bcd0e38ddf

View File

@ -1,37 +1,25 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define MAX 20 #define MAX 20
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);
}
int main() { int main() {
//int l = i * 2 + 1; //int l = i * 2 + 1;
//int r = i * 2 + 2; //int r = i * 2 + 2;
struct node* root;
int i,n; int i,n;
int *a = calloc(MAX, sizeof(int)); int *a = calloc(MAX, sizeof(int));
for (i = 0; i < MAX; i++) { for (i = 0; i < MAX; i++) {
scanf("%d", &root->data); scanf("%d", &a[i]);
if(a[i]!=0){ if(a[i]!=0){
n++; n++;
} }
} }
printf("Je to taka kopa:\n"); printf("Je to taka kopa:\n");
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
printf("%d\n", a[i]); printf("%d\n", a[i]);
if(a[i+1]!=0){ if(a[i+1]!=0){//&&a[i+1]>a[i]
printf(" ");
} }
} }
//preorderTraversal(root);
return 0; return 0;
} }