Question:
got some errors while compiling my code on quick sort?
Justivyke
2011-12-16 05:54:11 UTC
i am a beginner in c++. i got the following errors while compiling my program

algorithms.cpp: In function 'void sort_algorithms::quick_sort(int, int*)':
algorithms.cpp:162: error: expected primary-expression before ']' token
algorithms.cpp:162: error: expected primary-expression before 'int'
algorithms.cpp:163: error: expected ';' before '}' token
make: *** [algorithms.o] Error 1


below are my programms

void sort_algorithms::quick_sort(int num,int array[])
{
162 quick_sort(array[], int 0, int num-1)
163}
void sort_algorithms::quick_sort(int array[],int p, int r)
{
int q;
if(p {
q=partition(array,p,r);
quick_sort(array,p,q-1);
quick_sort(array,q+1,r);
}
}
int sort_algorithms::partition(int array[], int p, int r)
{
int x=array[r];
int i= p-1;
int temp;
for (int j=p;j {
if (array[j]<=x)
{
i=i+1;
temp=array[i];
array[i]=array[j];
array[j]=temp;
}
}
temp=array[i+1];
array[i+1]=array[r];
array[r]=temp;
return i+1;
}

thank you for your help
Three answers:
warpjedi
2011-12-16 06:06:47 UTC
void sort_algorithms::quick_sort(int num,int array[])

{

162 quick_sort(array[], int 0, int num-1)

163}



Don't specify the data type when calling a function. Should be:



void sort_algorithms::quick_sort(int num,int array[])

{

quick_sort(array, 0, num-1)

}
Will H
2011-12-16 06:14:34 UTC
void sort_algorithms::quick_sort(int num,int array[])

{

quick_sort(array, 0, num-1);

}
anonymous
2016-12-01 10:18:57 UTC
i be attentive to that i did this question a together as in the past yet for what's well worth, The physique of innovations that we finnally went for became into: finding the archives that have been mentioned as too long. shrink the full course lenght of those archives, by utilizing reducing the lenght of the call and/or the lenght of the field folder or reducing the folder nesting point. Therefor reducing the full course lenght. replace the links of the replaced archives (re-linking) on the dependant initiatives. This solved the subject with seen Studio 2012 on builders workstations and on our CI/setting up servers that used msbuild. For my state of affairs this approch became into much less risky,and implied much less attempt than shifting finished initiatives/suggestions to chop back their folder nesting point or reducing the folder names, and could replace each and all the references of the dependant undertaking/suggestions.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...