Skip to content

Instantly share code, notes, and snippets.

@agiletalk
Created March 23, 2011 06:05
Show Gist options
  • Save agiletalk/882689 to your computer and use it in GitHub Desktop.
Save agiletalk/882689 to your computer and use it in GitHub Desktop.
rand() 함수 사용 예제
#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