Advertisement
Broatlas

connect

Feb 5th, 2016
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.49 KB | None | 0 0
  1. /*****************************************************************************
  2. *Robert Taracha
  3. *Connect.c
  4. *****************************************************************************/
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. /********************************
  8. int numRandom(int min, int max);
  9. ***********************************/
  10.  
  11.  
  12. int main(void) {
  13.         int max = 10, min = 0;
  14.         int count = 0;
  15.         static int p[10];
  16.         static int q[10];
  17.         int *tempp, *tempq;
  18.         int test = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  19.         int *i ;
  20.         printf("filling both arrays");
  21.         /* fill p and q  */
  22.         for(count;count < max;count++){
  23.                 p[count] = numRandom(min, (max - 1));
  24.                 q[count] = numRandom(min, (max - 1));
  25.         }
  26.  
  27.         for(count = 0;count < max;count++){
  28.                  tempp = (int) p[count];
  29.                  tempq = (int) q[count];
  30.                 if(test[tempp] != test[tempq]){
  31.                         test[tempp] = test[tempq];
  32.                 }
  33.                 printf("%d", test[count]);
  34.                 i++;
  35.         }
  36.         prtinf("Finshed");
  37.  
  38.         return 0;
  39. }
  40.  
  41.  
  42.  
  43. /*********************************************/
  44.  
  45. int numRandom(int min, int max) {
  46.  
  47.         return rand() % (max - min + 1) + min;
  48.  
  49. }
  50. /*************************************************/
  51.  
  52. ~                                                                                                        
  53. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement