#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int arr_1[10] = { 1,2,3,4,5,6,7,8,9,0 };//array[],数组的声明格式 []里面必须是一个确定的数,表示数组里面的数的个数
int arr_2[] = { 1,2,3,4,5,6,7,8,9,0 };//[]里面可以不用写数组的个数,根据数组{}包含的实际个数系统自动分配地址
int arr_3[10]; //后面数组的内容可以暂时不写,但要确定数组里面的数的个数
int arr_4[10] = { 1,2,3 };//不完全初始化,其余位数会自动默认为0
//打印数组 用循环语句逐个打印
int i;
for (i = 0; i < 10; i++)//数组从array[0]开始计算 所以i=0
{
printf("%d ", arr_4[i]);
}
}
数组的初始化和打印
于 2022-04-08 19:50:46 首次发布