看代码:
#include
#include
void print_arr (int* a, int n)
{
int i = 0;
for (; i < n; ++i)
{
printf ("%d ", a[i]);
if ((i+1) % 10 == 0)
{
printf("\n");
}
}
printf("\n");
}
#define N 50
int main(int argc, char** argv)
{
srand(time(NULL)); // 设置当前时间为随机数种子
int a[N], i;
for (i = 0; i < N; i++)
{
a[i] = rand() % 100 + 100;
}
print_arr(a, N);
return 0;
}
运行: