Skip to content

Instantly share code, notes, and snippets.

@nuryslyrt
Created November 25, 2011 17:10
Show Gist options
  • Save nuryslyrt/1393989 to your computer and use it in GitHub Desktop.
Save nuryslyrt/1393989 to your computer and use it in GitHub Desktop.
random sayılar üretiyor.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int printRandomNumbers(int limit) {
char status[limit];
int i, j, sayac, random, k;
for(i = 0; i<limit; i++)
status[i] = 'f';
sayac = limit;
for(i=0;i<limit;i++) {
random = rand()%sayac+1;
k = 0;
for(j=0;j<limit;j++) {
if(status[j] == 'f')
k++;
if(k == random) break;
}
printf("%i\n", j);
status[j] = 't';
sayac = sayac-1;
}
}
int main(void) {
char status[50];
char i, j;
srand ( time(NULL) );
return printRandomNumbers(50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment