a3
This commit is contained in:
parent
65731c0c48
commit
1fc83d9839
24
a3/program.c
24
a3/program.c
@ -1,25 +1,37 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#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 l = i * 2 + 1;
|
||||
//int r = i * 2 + 2;
|
||||
struct node* root;
|
||||
int i,n;
|
||||
int *a = calloc(MAX, sizeof(int));
|
||||
for (i = 0; i < MAX; i++) {
|
||||
scanf("%d", &a[i]);
|
||||
scanf("%d", &root->data);
|
||||
if(a[i]!=0){
|
||||
n++;
|
||||
}
|
||||
}
|
||||
//m = buildmaxheap(a, n);
|
||||
|
||||
printf("Je to taka kopa:\n");
|
||||
for (i = 0; i < n; i++) {
|
||||
/*for (i = 0; i < n; i++) {
|
||||
printf("%d\n", a[i]);
|
||||
if(a[i+1]!=0){//&&a[i+1]>a[i]
|
||||
printf(" ");
|
||||
}
|
||||
if(a[i+1]!=0){
|
||||
}
|
||||
}*/
|
||||
preorderTraversal(root);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user