Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #define ARR_SIZE 4
- #define MAX 10
- typedef int Secret[ARR_SIZE];
- void fyllArray(Secret hemligtTal[])
- {
- int i;
- int j;
- int hasDuplicate;
- for(i=0;i<ARR_SIZE;i++)
- {
- hemligtTal[i] = rand() % MAX;
- printf("array[%d] = %d\n\n", i, hemligtTal[i]);
- hasDuplicate = 0;
- for(j=0; j<=(i-1); j++)
- {
- if (hemligtTal[i] == hemligtTal[j])
- {
- hasDuplicate = 1;
- i--;
- }
- }
- }
- }
- int main()
- {
- Secret hemligtTal;
- srand(time(NULL));
- fyllArray(hemligtTal);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment