//
// main.c
// 数组的遍历
//
// Created by Jason on 16/6/7.
// Copyright © 2016年 Jason. All rights reserved.
//
#include <stdio.h>
int main(int argc, const char * argv[]) {
//数组的遍历
int scorce[3] = {10,11,12};
for (int i = 0; i < 3; i++) {
printf("%d \n" , scorce[i]);
}
//部分静态初始化
int scoress[30] = {10};
for (int j = 0; j < 30; j++) {
printf("scoress[%d] = %d \n",j,scoress[j]);
}
//部分动态初始化 没有被初始化的元素中 是有值得 是垃圾值
int scoresss[30];
scoresss[0] = 10;
scoresss[1] = 11;
for (int k = 0; k < 30; k++) {
printf("scoresss[%d] = %d \n",k,scoresss[k]);
}
//假设有数组
int a[10] = {1,2,3,4,5,6,7,8,9,0};
//1.正序输出
for (int i = 0; i < 10; i++) {
printf("%d \n",a[i]);
}
int b[10] = {1,2,3,4,5,6,7,8,9,0};
//1.逆序输出
for (int i = 9;i >= 0; i--) {
printf("%d \n" ,b[i]);
}
return 0;
}
时间: 2024-10-13 00:09:35