3-5&&6 Array


遍历二维数组的三种方式

#include
#include
#include
using namespace std;
int main(){
    //初始化二维数组
    int map[3][4] = {};
    for(int cow = 0; cow < 3; cow++)
        for(int col = 0; col < 4; col++)
            map[cow][col] = cow+col;
	
    //第一种方法:范围for【外层for必须要用引用,否则cow会被转换为指针,而指针不支持内层的范围f】
    cout<<"the first version : use range for"<

相关