Created
June 16, 2013 12:08
-
-
Save wfwei/5791854 to your computer and use it in GitHub Desktop.
User rand7 to rand10
This file contains hidden or 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> | |
| // 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