无意间看到这个问题,平时对二位数组和多维数组接触也比较少,就尝试了一下,挺简单的。O(∩_∩)O~~
# include <stdio.h>
int main( void )
{
int i, j;
int arr[2][3] = { {1,2,3},{4,5,6} };
printf( "两行三列:\n" );
for( i = 0; i < 2; ++i )
{
for( j = 0; j < 3; ++j )
{
printf( "%d ", arr[i][j] );
}
printf( "\n" );
}
printf( "三行两列:\n" );
for( i = 0; i < 3; ++i )
{
for( j = 0; j < 2; ++j )
{
printf( "%d ", arr[j][i] );
}
printf( "\n" );
}
return 0;
}
/*
VC++6.0输出结果是
================================
两行三列:
1 2 3
4 5 6
三行两列:
1 4
2 5
3 6
================================
总结:
小程序一个,没啥可总结,哈哈
*/
学PHP的小蚂蚁 博客 http://my.oschina.net/woshixiaomayi/blog