Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- SNS
- 풀스택프레임워크
- 코테
- backend
- 코딩독학
- 모의 주식
- java정리
- 사물인터넷
- Python
- Project
- Reflex
- 개발
- 코딩테스트
- 개인프로젝트
- C++
- 프로그래밍
- 빅데이터
- 주가예측
- 자바독학
- 자바정리
- 백준
- 프로그래머스
- 이웃한 칸
- 코스닥
- java
- 개발자
- 자바
- 프로그램
- frontend
- 코딩
Archives
- Today
- Total
Creative Code
main.c(함수 선언) 본문
#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);
}
'C Programming' 카테고리의 다른 글
main.c(serial함수) (0) | 2023.08.04 |
---|---|
main.c(rand함수) (0) | 2023.08.04 |
main.c (랜덤함수 라이브러리 생성) (0) | 2023.08.04 |
swap3.c(전역변수 사용) (0) | 2023.08.04 |
bowling.c(볼링 점수 계산) (0) | 2023.08.03 |