Created
March 23, 2011 06:05
-
-
Save agiletalk/882689 to your computer and use it in GitHub Desktop.
rand() 함수 사용 예제
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> // srand(), rand() | |
#include <time.h> // time() | |
int main() | |
{ | |
int random; | |
// rand 함수로 난수를 만들고 3으로 나눈 나머지로 0, 1, 2만 나오도록 한다. | |
srand((unsigned)time(NULL)); | |
random = rand() % 3; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment