Hello, dear all!
Below is heap algorithm. the problem is the output is not appear. How to fix it?
#include <stdio.h>
#include <iostream>
using namespace std;
int *Value;
int N;
void read (int N)
{ int i;
for (i = 0; i< N; i++)
{ cout << Value[i] << "";
}
}
void swap(int i,int j)
{
int t;
t=Value[i];
Value[i]=Value[j];
Value[j]=t;
}
void HeapPermute(int N)
{ int i;
read (N);
for (i=0;i<N;i++) {
HeapPermute(N-1);
if (N%2 == 1)
swap(0,N-1);
else
swap(i,N-1);
}
}
void initiate (int N)
{ int i;
for(i=0; i<N; i++)
{
Value[i]=i+1;
}
}
int main()
{
cout << " Enter the Size of elements ";
cin >> N;
initiate (N);
HeapPermute(N);
}