srand 설명 난수 발생기를 초기화 시킨다. 문법 #include<stdlib.h> void srand(unsigned seed); 기능 rand() 실행시 난수값이 일정한데 srand() 을 이용하여 초기화 시켜준다. 리턴값 없음 사용법 #include <stdlib.h> #include <stdio.h> #include <time.h> main() { int i; time_t t; srand(time(&t)); pr…
난수 ( rand,srand ) 헤더파일에 #include<stdlib.h> 포함 하고 있어야 된다. 실행할때마다 값이 다르게 나오게 한다. #include<stdio.h> #include<stdlib.h> // srand() 와 rand() 를 위하여 .. #include<time.h> // time() 을 위하여 .. main() { int i,Xrand; srand(time(NULL)); // 시간으로 초기화 .. for(…