c语言程序设计的字符串

 

给你答了一遍了。

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
	int a[20],i;
	srand((unsigned int)time(0));
	for(i=0;i<20;i++)
	{
		a[i] = rand()%1000;  //生成0-999的随机数,如果不限定范围就直接用 a[i]=rand()
		if( (i-4)%5 == 0)
			printf("%d\n",a[i]);
		else
			printf("%d ",a[i]);
	}
	return 0;
}

 

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <Windows.h>

int main(void)
{
	//随机数种子
	srand((unsigned int)time(NULL));
	int array[20] = { 0 };
	for (int i = 0; i < 20; i++)
	{
		array[i] = rand()%100; //0-99任意数
	}

	//输出
	int i = 0;
	while (i < 20)
	{
		printf("%d ", array[i]);
		i++;
		if (i % 5 == 0)
		{
			printf("\n");
		}
	}
	printf("\n");
	system("pause");
	return EXIT_SUCCESS;
}