From 067c0e6a75b80bda51ebce8e37317c24057e5974 Mon Sep 17 00:00:00 2001 From: "eunganiya89@wku.ac.kr" Date: Fri, 24 Sep 2021 17:33:31 +0900 Subject: [PATCH] srand() --- ...수와 time()함수를 사용한 숫자 6개를 출력.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 srand()함수와 time()함수를 사용한 숫자 6개를 출력.c diff --git a/srand()함수와 time()함수를 사용한 숫자 6개를 출력.c b/srand()함수와 time()함수를 사용한 숫자 6개를 출력.c new file mode 100644 index 0000000..f960c97 --- /dev/null +++ b/srand()함수와 time()함수를 사용한 숫자 6개를 출력.c @@ -0,0 +1,21 @@ +#include +#include +#include + +#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; + +} \ No newline at end of file