用一个一级的指针指向二维数组,然后那个指针可以像一维数组排序那样用,因为二维数组也是连续的.
例如:
#include <iostream>
#include <algorithm>
void func(int n)
{
std::cout < <n < <" ";
}
int main()
{
int a[3][3]={1,9,3,7,5,6,2,8,4};
std::sort((int*)a,&a[2][3]);
std::for_each((int*)a,&a[2][3],func);
system("pause");
return 0;
}
你可以参考一下这个网址:
http://topic.csdn.net/u/20071229/13/a7f1a240-fe88-49b1-b527-440ffda0cf55.html