Creative Code

dice.c(주사위 값 srand함수) 본문

C Programming

dice.c(주사위 값 srand함수)

빛하루 2023. 8. 2. 10:44
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
	srand(time(NULL)); // seed, 1970년 1월1일부터 몇 초가 지나는지 파악(즉 1초이내에 파일을 두 번이상 사용하면 소용 x)
	for (int i = 1; i<=10; i++){
		int num = rand()%6+1;
		printf("%d\n",num);
	}
	return 0;
}

'C Programming' 카테고리의 다른 글

lotto.c (로또 번호 생성)  (0) 2023.08.02
baseball.c(숫자 야구게임)  (0) 2023.08.02
dice.c (주사위 값 rand함수)  (0) 2023.08.02
bubbleSorting.c ( 배열 버블정렬)  (0) 2023.08.02
selectionSorting.c (배열 값 정렬)  (0) 2023.08.02