void radix(int data[],int n);
int main()
{
int number=9;
int data[]={5,6,4,8,2,3,7,9,1};
int i;
for (i=0;i<number;i++){
printf("%d",data[i]);
}
printf("\n");
radix(data,number);
printf("\n");
for (i=0;i<number;i++){
printf("%d",data[i]);
}
printf("\n");
system("PAUSE");
return 0;
}
void radix(int data[],int n){
int k,i,j,z;
int m;
for (z=1;z<=100;z=z*10){
int temp[10][100]={0};
for (i=0;i<n;i++){
m=data[i]/z%10;
temp[m][i]=data[i];
}
k=0;
for (i=0;i<10;i++){
for (j=0;j<n;j++){
if (temp[i][j]!=0){
data[k]=temp[i][j];
k++;
}
}
}
}
}
沒有留言:
張貼留言