Advertisement
Broatlas

Random arry

Feb 4th, 2016
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. /********************************
  4. int numRandom(int min, int max);
  5. int * arryRandom();
  6. ***********************************/
  7.  
  8.  
  9. int main(void) {
  10.         int max = 10, min = 0;
  11.         int count = 0;
  12.         int *p;
  13.         p = arryRandom();
  14.  
  15.         for(count;count < max;count++){
  16.                 printf("*(p + %d) : %d\n", count, *( p + count ));
  17.         }
  18.         return 0;
  19. }
  20.  
  21.  
  22.  
  23. /*********************************************/
  24.  
  25. int numRandom(int min, int max) {
  26.  
  27.         return rand() % (max - min + 1) + min;
  28.  
  29. }
  30. /*************************************************/
  31.  
  32. int * arryRandom() {
  33.  
  34.         int i;
  35.         int arry[10];
  36.  
  37.         srand( (unsigned)time( NULL ) );
  38.  
  39.         for (i = 0; i < 10; i++) {
  40.                 arry[i] = numRandom(0, 9);
  41.         }
  42.  
  43.         return arry;
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement