C Programming
main.c(함수 선언)
빛하루
2023. 8. 4. 10:43
#include <stdio.h>
#include <time.h>
void my_srand(int); // function declaration 함수 선언(미리 선언을 해두면 main 함수 밑에 함수를
쓰거나 다른.c파일에 분리를 하더라도 참조할 수 있다.
int my_rand(void);
int main(void)
{
my_srand(time(NULL));
for (int i = 1; i<=10; i++) {
int num = my_rand();
printf("%d\n",num);
}
return 0;
}
int seed;
void my_srand(int s) // function definition
{
seed = s;
}
int my_rand(void)
{
seed = 1103515245 * seed +12345;
return ((unsigned)(seed/65536)%32768);
}