C语言输出随机数

rand()函数

#include "stdio.h"
#include "stdlib.h"
#include "time.h" 


int main(){
	int i,num;
	srand(time(0));
	for(i=0;i<10;i++){
		num=rand()%10+1;
		printf("%d\n",num);
	}
		printf("\n");
	system("pause");
	return 0;
}

posted @ 2022-11-08 15:03  有何和不可  阅读(68)  评论(0)    收藏  举报