Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. int main(void)
  2. {
  3. int array[] = {1, -1, 2, 3, 4, -5, 6};
  4. int cnt = sizeof(array)/sizeof(array[0]);
  5. int *neg, *pos;
  6. int **low = &neg;
  7. int **high = &pos;
  8.  
  9. neg = (int*) malloc(sizeof(int) * 2);
  10. pos = (int*) malloc(sizeof(int) * 5);
  11.  
  12. sort(array, cnt, low, high);
  13.  
  14. for(int i = 0; i < 5; i++)
  15. {
  16. printf("%3dn", pos[i]);
  17. }
  18.  
  19. //same for negative array
  20.  
  21. return 0;
  22.  
  23. }
  24.  
  25. int sort(int *arr, int cnt, int **low, int **high)
  26. {
  27. for(int i = 0; i < cnt; i++)
  28. {
  29. if(array[i] > 0)
  30. {
  31. *high[0] = arr[i];
  32. **high++;
  33. }
  34. else
  35. {
  36. *low[0] = arr[i];
  37. **low++;
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement