question about qsort in c++
- by davit-datuashvili
i have following code in c++
#include <iostream>
using namespace std;
void qsort5(int a[],int n){
int i;
int j;
if (n<=1)
return;
for (i=1;i<n;i++)
j=0;
if (a[i]<a[0])
swap(++j,i,a);
swap(0,j,a);
qsort5(a,j);
qsort(a+j+1,n-j-1);
}
int main()
{
return 0;
}
void swap(int i,int j,int a[])
{
int t=a[i];
a[i]=a[j];
a[j]=t;
}
i have problem
1>c:\users\dato\documents\visual studio 2008\projects\qsort5\qsort5\qsort5.cpp(13) : error C2780: 'void std::swap(std::basic_string<_Elem,_Traits,_Alloc> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : expects 2 arguments - 3 provided
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(2203) : see declaration of 'std::swap'
1>c:\users\dato\documents\visual studio 2008\projects\qsort5\qsort5\qsort5.cpp(13) : error C2780: 'void std::swap(std::pair<_Ty1,_Ty2> &,std::pair<_Ty1,_Ty2> &)' : expects 2 arguments - 3 provided
1> c:\program files\microsoft visual studio 9.0\vc\include\utility(76) : see declaration of 'std::swap'
1>c:\users\dato\documents\visual studio 2008\projects\qsort5\qsort5\qsort5.cpp(13) : error C2780: 'void std::swap(_Ty &,_Ty &)' : expects 2 arguments - 3 provided
1> c:\program files\microsoft visual studio 9.0\vc\include\utility(16) : see declaration of 'std::swap'
1>c:\users\dato\documents\visual studio 2008\projects\qsort5\qsort5\qsort5.cpp(14) : error C2780: 'void std::swap(std::basic_string<_Elem,_Traits,_Alloc> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : expects 2 arguments - 3 provided
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(2203) : see declaration of 'std::swap'
1>c:\users\dato\documents\visual studio 2008\projects\qsort5\qsort5\qsort5.cpp(14) : error C2780: 'void std::swap(std::pair<_Ty1,_Ty2> &,std::pair<_Ty1,_Ty2> &)' : expects 2 arguments - 3 provided
1> c:\program files\microsoft visual studio 9.0\vc\include\utility(76) : see declaration of 'std::swap'
1>c:\users\dato\documents\visual studio 2008\projects\qsort5\qsort5\qsort5.cpp(14) : error C2780: 'void std::swap(_Ty &,_Ty &)' : expects 2 arguments - 3 provided
1> c:\program files\microsoft visual studio 9.0\vc\include\utility(16) : see declaration of 'std::swap'
1>c:\users\dato\documents\visual studio 2008\projects\qsort5\qsort5\qsort5.cpp(16) : error C2661: 'qsort' : no overloaded function takes 2 arguments
1>Build log was saved at "file://c:\Users\dato\Documents\Visual Studio 2008\Projects\qsort5\qsort5\Debug\BuildLog.htm"
please help