#include <iostream>
bool CheckSort(int * pSource, int N);
bool Sort(int * pSource, int N);
int main()
{
using std::cout;
using std::endl;
const int SIZE =10;
int a[10] ={-65,10,33,-2,81,-89,0,14,142,3};
bool isSort = false,isSortStatus;
isSortStatus =CheckSort(a,SIZE);
if (isSortStatus)
cout <<"Sorted...\n";
else
cout <<"Unsorted..\n";
/////////////////////////////////////////////
cout<<">>>Sorting...\n";
isSort =Sort(a,SIZE);
if (isSort)
for (int i = 0; i
cout<< i+1<< "--->"<< a[i]<< endl;
else
cout << "Sortfail.\n";
////////////////////////////////////////////
isSortStatus =CheckSort(a,SIZE);
if (isSortStatus)
cout <<"Sorted...\n";
else
cout <<"Unsorted..\n";
return 0;
}
bool CheckSort(int * pSource, int N)
{
bool Check =false;
for (int i=0; i
{
if ( *(pSource+i) <=*(pSource+i+1) )
Check =true;
else
Check =false;
if (!Check)
break;
}
return Check;
}
bool Sort(int * pSource, int N)
{
int tmp;
for (int i=0; i
{
for (int j=0; j
{
if (*(pSource+j) > *(pSource+j+1) )
{
tmp = *(pSource+j);
*(pSource+j) =*(pSource+j+1);
*(pSource+j+1) = tmp;
}
}
}
return true;
}