C语言中,定义一个空数组,然后定义一个循环语句随便哪种,

Python015

C语言中,定义一个空数组,然后定义一个循环语句随便哪种,,第1张

#include<stdio.h>

main()

int a【100】;

int i,x;

scanf(“%d”,&x)

for(i=0;i<100;i++)

a【i】=(i+1)*x

for(i=0;i<100;i++)

printf(“%d ”,a【i】)

用iPad打的 有的符号可能不准确 建议改一下符号

很简单,定义一个指定长度(必须有)的数组,不初始化就可以了,最好指定一下存储段,在访问时可以优化一些。

例:

int data address[20] /* 整型数组,名称 address,长度 20,存储在 data 段 */

char idata name[10]/* 字符数组,名称 name,长度 10,存储在 idata 段 */

long xdata table[100]/* 长整型数组,名称 table, 长度 100,存储在 xdata 段 */