#include
#include
void build(int*, int );
void heap(int*, int);
int main(void)
{
FILE *fin;
int *a,n,i;
fin=fopen("input.txt", "r");
fscanf(fin,"%d", &n);
a=(int*)malloc(n*sizeof(int));
for (i=0; i"pervona4alniy vid\n");
for (i=0; i"\n");
build(a, n);
printf("\n postroenie\n");
for (i=0; i"\n kone4niy vid\n");
for (i=0; i"\n");
return 0;
}
/* ------------ */
void build(int *a, int n)
{ int i,j,k,temp;
for (i=0; ia[j])&&(j+10)&&(a[j]>a[k]))
{
temp=a[j];
a[j]=a[k];
a[k]=temp;
j=k;
k=(k-1)/2;
} }
}
/* -------------*/
void heap(int *a, int n)
{ int nn,temp,i;
nn=n;
while (nn>0)
{
temp=a[0];
a[0]=a[nn-1];
a[nn-1]=temp;
nn--;
build(a,nn);
for (i=0; i