Guest User

Untitled

a guest
Mar 8th, 2011
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #define ARR_SIZE 4
  4. #define MAX 10
  5.  
  6. typedef int Secret[ARR_SIZE];
  7.  
  8. void fyllArray(Secret hemligtTal[])
  9. {
  10.     int i;
  11.     int j;
  12.     int hasDuplicate;
  13.  
  14.  
  15.     for(i=0;i<ARR_SIZE;i++)
  16.     {
  17.         hemligtTal[i] = rand() % MAX;
  18.  
  19.         printf("array[%d] = %d\n\n", i, hemligtTal[i]);
  20.  
  21.         hasDuplicate = 0;
  22.  
  23.         for(j=0; j<=(i-1); j++)
  24.             {
  25.                 if (hemligtTal[i] == hemligtTal[j])
  26.                 {
  27.                     hasDuplicate = 1;
  28.                     i--;
  29.                 }
  30.  
  31.             }
  32.     }
  33. }
  34.  
  35. int main()
  36. {
  37.     Secret hemligtTal;
  38.  
  39.     srand(time(NULL));
  40.  
  41.  
  42.     fyllArray(hemligtTal);
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment