witam
napisalem klase imitujaca dzialanie kopca:
class Heap
{
public:
Heap(int max_size)
{
t=new int[max_size+1];
current_size=0;
};
//**********************************************
void insert_int(int x)
{
t[++current_size]=x;
GoUp();
}
//**********************************************
void GoUp()
{
int temp=t[current_size];
int n=current_size;
while((n!=1) && (t[n/2]<=temp))
{
t[n]=t[n/2];
n=n/2;
}
t[n]=temp;
}
//**********************************************
int get_first()
{
int x=t[1];
t[1]=t[current_size--];
GoDown();
return x;
}
//**********************************************
void GoDown()
{
int i=1;
while(true)
{
int p=2*i;
if(p>current_size)
break;
if(p+1<=current_size)
if(t[p]<t[p+1])
p++;
if(t[i]>=t[p])
break;
int temp=t[p];
t[p]=t[i];
t[i]=temp;
i=p;
}
}
private:
int *t;
int current_size;
};
otóż gdy w funkcji main napisze:
Heap S(13);
to program po uruchomienu mi sie wywala.
moglby ktos pomoc lub wskazac ewentualne bledy jakie popelnilem?
bede wdzieczny za kazda pomoc
vpiotr