#include "stdafx.h"
#include<iostream>
using namespace std;
class index
{
int i,j,temp;
public:
void indexsort(int *a)
{
for(i=0;i<9;i++)
for(j=i+1;j<10;j++)
if(a[i]>a[j])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
};
int _tmain(int argc, _TCHAR* argv[])
{
index obj;
int s[10]={2,3,4,5,1,0,9,6,8,7};
obj.indexsort(s);
int *p=s;
for(int i=0;i<10;i++)
{
cout<<*p++<<endl;
}
return 0;
}
实现结果是这样的: