Honghui (James) Chen 's Blog
Welcome
Sunday, 30 September 2012
Classical Programming - 5 : exchange sort (c++)
void ExchangeSort(int* pData,int Count)
{
int iTemp;
for(int i=0;i<Count-1;i++) {
for(int j=i+1;j<Count;j++) {
if(pData[j]<pData[i]) {
iTemp = pData[i];
pData[i] = pData[j];
pData[j] = iTemp;
}
}
}
}
Saturday, 29 September 2012
Classical Programming - 4 : bubble sort (c++)
void BubbleSort(int* Data,int Count) {
int iTemp;
for(int i=1;i<Count;i++) {
for(int j=Count-1;j>=i;j--) {
if(Data[j]<pData[j-1]) {
iTemp = Data[j-1];
Data[j-1] = pData[j];
Data[j] = iTemp;
}
}
}
}
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)