c/school/ch08_8-21.c · 563 字节 · 下载原文
#include <stdio.h>
/*
7
34 98 56 12 22 65 1
*/
int L[100],n;
int* P1[100];
int **P2;
void sort(int n){
for(int i=1;i<=n;i++){
for(int j=1;j<=n-i;j++){
if(**(P2+j)>**(P2+j+1)){
int* tmp=*(P2+j);
*(P2+j)=*(P2+j+1);
*(P2+j+1)=tmp;
}
}
}
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
// L+i==&L[i]
scanf("%d",L+i);
P1[i]=&L[i];
}
P2=P1;
sort(n);
for(int i=1;i<=n;i++)
printf("%d ",**(P2+i));
}