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