C语言数组操作

1.数组定义

int a[5]

int a[5] = {1,2,3}

int a[]={1,2,3,4,5}

int a[5]={1,2,3,4,5}

例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# include <stdio.h>
int main(void)
{
int a[5] = {0}; //数组清零初始化
int i;
printf("请输入5个数:");
for (i=0; i<5; ++i)
{
scanf("%d", &a[i] );
}
for (i=0; i<5; ++i)
{
printf("%d\x20", a[i]);
}
printf("\n");
return 0;
}