2 一维数组练习
定义一个100长度的整型数组,使用rand函数生产随机数对每个元素进行赋值,顺序遍历该数组,输出所有值大于50的数。输出格式例子为:
a[1]=100
a[5]=70
a[20]=90
/* Note:Your choice is C IDE */
#include "stdio.h"
#include "stdlib.h"
#define LEN 100
main()
{
int i,temp;
int a[LEN];
for(i=0;i<LEN;i++){
temp=rand();
if(temp>50)
{
printf("a[%d]=%d\n", i,temp);
}
}
}