C语言基础:输出二维数组
#include <stdio.h> int main(void) { int row, column; float table[3][5] = {{1.0, 2.0, 3.0, 4.0, 5.0}, {6.0, 7.0, 8.0, 9.0, 10.0}, {11.0, 12.0, 13.0, 14.0, 15.0}}; for (row = 0; row < 3; row++) for (column = 0; column < 5; column++) printf("table[%d][%d] = %f\n", row, column, table[row][column]); return 1; }
输出结果
table[0][0] = 1.000000 table[0][1] = 2.000000 table[0][2] = 3.000000 table[0][3] = 4.000000 table[0][4] = 5.000000 table[1][0] = 6.000000 table[1][1] = 7.000000 table[1][2] = 8.000000 table[1][3] = 9.000000 table[1][4] = 10.000000 table[2][0] = 11.000000 table[2][1] = 12.000000 table[2][2] = 13.000000 table[2][3] = 14.000000 table[2][4] = 15.000000