实现输出:
7 8 9 10
6 1 2 11
5 4 3 12
16 15 14 13
最简单的是采用定制输出:
int main() { int cnt=1;int *p; int a[4][4]={{7,8,9,10},{6,1,2,11},{5,4,3,12},{16,15,14,13}}; p=a[0]; cout<<"the matrix is:"<<endl; while (*p && cnt<= 16) { cout<<*p<<" "; p++; if (cnt %4 ==0) { cout<<endl; } cnt++; } system("pause"); return 0; }