【C语言编程】将二维数组逆序输出 | 您所在的位置:网站首页 › 数组逆序输出的c程序 › 【C语言编程】将二维数组逆序输出 |
/原数组
A = [ 1 3 5 7 9 11 13 15 17 19 21 23 ] A=\left[ \begin{matrix} 1 & 3 & 5\\ 7 & 9 & 11 \\ 13 & 15 & 17\\ 19 & 21 & 23 \end{matrix} \right] A=⎣⎢⎢⎡1713193915215111723⎦⎥⎥⎤ 更新后数组A = [ 23 21 19 17 15 13 11 9 7 5 3 1 ] A=\left[ \begin{matrix} 23 & 21 & 19\\ 17 & 15 & 13 \\ 11 &9 & 7\\ 5 & 3 & 1 \end{matrix} \right] A=⎣⎢⎢⎡2317115211593191371⎦⎥⎥⎤ #include int main() { void sort(int x[][3], int n); int a[4][3]={ 1,3,5,7,9,11,13,15,17,19,21,23}; int i,j,count=0; for(i=0;i printf("%2d ", a[i][j]); count++; if(count%4==0) //按3x4输出 printf("\n") ; } printf("%d", a[2][0]); return 0; } void sort(int x[4][3], int n) { //临时变量用来交换 int i, j, k; k=n-1; int temparray[n]; for(i=0;i x[i][j] = temparray[k]; k++; } }版权声明 本文为[t4ngw]所创,转载请带上原文链接,感谢 https://blog.csdn.net/t4ngw/article/details/121854265 |
CopyRight 2018-2019 实验室设备网 版权所有 |