i found a way to random generate 4 unique numbrs but prob is sometimes it doesn't run
i found a way to random generate 4 unique numbrs but prob is sometimes it doesn't run.. pls help me what are tne necessary changes i should do. here's the code i did:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void rep(int *, int*, int*,int*);
int main(void)
{
int i, n=4, a, b,c,d;
srand(time(NULL));
for (i=0; i < n; ++i) {
a= rand() % 10;
b= rand() % 10;
c= rand()%10;
d= rand()%10;
};
rep(&a,&b,&c,&d);
return 0;
}
void rep(int*a, int*b,int*c,int*d)
{
int tmp;
if (*a !=*b)
{tmp = *b;
*b = tmp;
{if(*a!=*c)
{if(*b!=*c)
{if(*a!=*d)
{if(*b!=*d)
{if(*c!=*d)
printf("%d %d %d %d\n",*a,*b,*c,*d);} } } } }
return;
}
else
main();
}
|