09-c数组的遍历
#include <stdio.h>
int main(int argc, const char * argv[]) {
// 取出数组中所有的值, 称之为遍历
int scores[6] = {1, 23, 44, 66, 71, 88, 99 , 2};
// 注意: 在遍历数组的时候, 尽量不要把遍历的次数写死
// 遍历多少次应该由数组来决定, 也就是说遍历多少次应该通过数组计算得出
// 动态计算数组的元素个数
int length = sizeof(scores) / sizeof(scores[0]);
for (int i = 0; i < length; i++) {
printf("scores[%i] = %i\n", i,scores[i]);
}
return 0;
}

浙公网安备 33010602011771号