Skip to content

Instantly share code, notes, and snippets.

@wfwei
Created June 16, 2013 12:08
Show Gist options
  • Select an option

  • Save wfwei/5791854 to your computer and use it in GitHub Desktop.

Select an option

Save wfwei/5791854 to your computer and use it in GitHub Desktop.
User rand7 to rand10
#include<stdio.h>
#include<stdlib.h>
// return random num:0-6
int Rand7(){
return rand()%7;
}
int Rand10(){
int rand71, rand72, rand10;
do{
rand71 = Rand7();
rand72 = Rand7();
rand10 = rand71*7 + rand72;
}while(rand10>=40);
return rand10/4 + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment