I've recently written a little program to test the C rand function found in . I've compiled it twice and ran it a multiple times. On every run, the same output was printed out:
2
2
6
3
5
3
Can someone point out the problem? Here is the code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int pick(int start, int end){
int num = ( rand()%end ) + start;
return num;
}
int main(){
int i;
for(i=0; i<6; i++){
printf("%d\n", pick(1, 6));
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire