Zdravim. Mam zadanie spravit program ktory do dynamickeho pola nacita "n" nahodnych cisiel a potom ich zotriedi a odmeria cas za ktory to zotriedil. Dostal som sa asi potialto:
#include <cstdlib>
#include <iostream>
#include <time.h>
#include <conio.h>
#include <stdlib.h>
using namespace std;
void ShakeSort(long A[], int n)
{ int lavy= 1, pravy= n-1, i,j,k;
do {
for (i= pravy; i>=lavy; i--)
if (A[i-1] > A[i ])
{ A[i-1]=j;
A[i]=A[i-1];
j=A[i];
k=i;
}
lavy=k+1;
for (i = lavy; i <=pravy; i++)
if (A[i-1 ] > A[i])
{ A[i-1]=j;
A[i]=A[i-1];
j=A[i];
k=i;
}
pravy=k -1;
} while (lavy<pravy);
}
int main(int argc, char *argv[])
{int n;
srand((unsigned) time(NULL));
clock_t Start, Koniec;
cin>>n;
long*A=new long[n+1];
for(int i=0;i<n;i++)
{
A[i]=rand()%10;
}
Start=clock();
ShakeSort(A,n);
Koniec=clock();
float Trvanie=(Koniec-Start)/CLOCKS_PER_SEC;
cout<<" Trvanie triedenia Shakesort: "<<Trvanie<<"s"<<endl;
for(int i=0;i<n;i++)
cout<<A[i];
system("PAUSE");
return EXIT_SUCCESS;
}
Nemeria cas a vypisuje mi tam nejake blbosti,ale aspon triedit mi triedi
... Prosim pomozte mi s tym..som v tom lama