随机数组
定义长度为20的一个数组,每个元素使用随机数来设置,输出这20个整数,要求每5个数一行
2014-11-27 17:26
程序代码:#include <stdio.h>
#include <stdlib.h>
#if _WIN32
#include <time.h>
#else
#include <sys/time.h>
#endif
int main()
{
srand((unsigned int)time(NULL));
for (int i = 0; i < 20; ++i)
{
printf("%d ", rand()%100);
if ((i + 1)%5 == 0)
printf("\n");
}
return 0;
}

2014-11-27 21:16