Изменить 'a3/program.c'
This commit is contained in:
parent
49aee5ab2c
commit
2baeb1743f
11
a3/program.c
11
a3/program.c
@ -61,7 +61,7 @@ void add(struct heap* h,int value){
|
|||||||
|
|
||||||
int i = h->size;//index prvka(posledny)
|
int i = h->size;//index prvka(posledny)
|
||||||
|
|
||||||
if(h->size>=capacity){
|
if(h->size>=h->capacity){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ void add(struct heap* h,int value){
|
|||||||
|
|
||||||
void print(struct heap* h,int count_spaces,int index){
|
void print(struct heap* h,int count_spaces,int index){
|
||||||
|
|
||||||
if(iindex>=h->size){
|
if(index>=h->size){
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ void print(struct heap* h,int count_spaces,int index){
|
|||||||
}
|
}
|
||||||
printf("%d\n",h->array[index]);
|
printf("%d\n",h->array[index]);
|
||||||
print(h,count_spaces+1,left_child(index));
|
print(h,count_spaces+1,left_child(index));
|
||||||
printAllRight(h,count_spaces+1,right_child(index));
|
print(h,count_spaces+1,right_child(index));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -104,14 +104,15 @@ int main(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct heap* h = create_heap(i);
|
struct heap* h = create_heap(i);
|
||||||
|
|
||||||
for(int j =0;j<i;j++){
|
for(int j =0;j<i;j++){
|
||||||
add(h,arr[j]);
|
add(h,temp_array[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
check_heap_property(h);
|
check_heap_property(h);
|
||||||
|
|
||||||
puts("Je to taka kopa:");
|
puts("Je to taka kopa:");
|
||||||
|
|
||||||
print(h);
|
print(h,0,0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user