方法一:普通的for循环

for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) {
        cout << a[i] << " ";
    }

方法二:指针数组

int *p[len];
for(int i = 0; i < len; i++){
        p[i] = &a[i];
        cout << *p[i];
} 
————————————————————————————————————
int *p = a;	
for(int i = 0; i < len; i++){
    cout << *(p + i);
}

方法三:数组指针(行指针)

 int (*p)[len];  // 注意数组指针的声明必须使用常量,确保它指向的数组的大小在编译时就已经确定,不能改变
    p = &a;
    for (int i = 0; i < len; i++) {
        cout << p[0][i] << endl;
        cout << *(*(p + 0) + i) << endl;
    }

方法四:范围for循环

for (auto i: a){  // i为临时变量,只有引用类型变量可以修改原数组
    cout << i << endl;
}
_____________________
for (auto& i: a){  // auto能够自动推导变量类型,引用类型除外
    cout << i << endl;
}

方法五:迭代器遍历

 for(auto i = begin(a); i != end(a); i++){  // 成员函数begin()和end()来获取遍历开始地址和遍历结束地址,同时,迭代器使用之后会自动回收
        cout << *i << endl;
    }