로딩
요청 처리 중입니다...

c언어 난수 발생기 프로그램

 c언어 난수 발생기 프로그램

#c언어 #난수발생기 #srand() 함수 #rand() 함수 난수 발생기 난수란 각각 같은 확률로 어느 하나를 선택하는 무작위 숫자를 의미합니다. rand 함수 및 srand 함수를 이용하여 난수를 내는 난수발생기를 작성하는 방법을 알아보겠습니다. /* 난수 발생기 */ #include #include #include void main(void) { int i; stand((unsigned)time(NULL)); for(i = 1; i <= 5; i++) { printf("난수%2d : %5d \n", i, rand() ); } for(i = 1; i <= 5; i++) { printf("난수%2d : %5d \n", i, rand()%10); } for(i = 1; i <= 10; i++) { printf("난수%d : %5d \n", i, rand()%10+50); } } srand 함수를 사용하기 위해서 헤더 파일 stdli...

# c언어 # rand # srand # 난수발생기