#include "stdio.h"#include <memory.h>void main(){int a[3][3]={{20,25,18},{15,26,9},{34,14,27}};int temp[3];int k,t;memcpy(temp,a[1],3);memcpy(a[1],a[0],3);memcpy(a[0],temp,3);for(k=0;k<3;k++){for(t=0;t<3;t++)printf(" %d ",a[k][t]);printf("\n");}}我想把數組a中a[3][3]={{20,25,18},{15,26,9},{34,14,27}};前兩行元素調換,即輸出15 26 920 25 1834 14 27可是結果卻是15 25 1820 26 934 14 27只有每行的第一個元素被調換了位置,為什么不是整體調換啊?
添加回答
舉報
0/150
提交
取消