fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int geraAleatorio(int min, int max) {
  6. return ((rand() % (max - min)) + min) + 1;
  7. }
  8.  
  9. int main(void) {
  10. srand((unsigned)time(NULL));
  11. printf("%d\n", geraAleatorio(10, 20));
  12. printf("%d\n", geraAleatorio(10, 20));
  13. printf("%d\n", geraAleatorio(30, 40));
  14. }
  15.  
  16. //http://pt.stackoverflow.com/q/186730/101
Success #stdin #stdout 0s 9416KB
stdin
Standard input is empty
stdout
19
16
34