【发布时间】:2013-03-16 18:32:17
【问题描述】:
我有 2 个数组
int n = 10;
int a[n];
int** t = new int*[n];
然后我将t 的i 元素指向a 的i 元素
然后我只想对t数组中的指针进行排序
然后我尝试对其进行冒泡排序,但它出错了
do{
for(int i = 0; i < n -1; i++){
if(*t[i] > *t[i+1]){
char* x = t[i];
t[i] = t[i+1];
t[i+1] = x;
}
n--;
}
}while(n>1);
【问题讨论】:
-
t 中的指针已经排序,因为 i'th 指向 a 中的第 i 个元素。
标签: c++ arrays sorting pointers int