Browse Source

srand()

master
eunganiya89@wku.ac.kr 5 years ago
parent
commit
067c0e6a75
  1. 21
      srand()함수와 time()함수를 사용한 숫자 6개를 출력.c

21
srand()함수와 time()함수를 사용한 숫자 6개를 출력.c

@ -0,0 +1,21 @@
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define NUM 45
int main(void)
{//srand() time() 6
int cnt;
printf("1~45 중에서 숫자 6개 출력\n");
srand((unsigned)time(NULL));
printf("srand() 출력 : ");
for (cnt = 1; cnt <= 6; cnt++)
printf("%d", 1 + (rand() % NUM));
printf("\n");
return 0;
}
Loading…
Cancel
Save