Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(void)
- {
- int array[] = {1, -1, 2, 3, 4, -5, 6};
- int cnt = sizeof(array)/sizeof(array[0]);
- int *neg, *pos;
- int **low = &neg;
- int **high = &pos;
- neg = (int*) malloc(sizeof(int) * 2);
- pos = (int*) malloc(sizeof(int) * 5);
- sort(array, cnt, low, high);
- for(int i = 0; i < 5; i++)
- {
- printf("%3dn", pos[i]);
- }
- //same for negative array
- return 0;
- }
- int sort(int *arr, int cnt, int **low, int **high)
- {
- for(int i = 0; i < cnt; i++)
- {
- if(array[i] > 0)
- {
- *high[0] = arr[i];
- **high++;
- }
- else
- {
- *low[0] = arr[i];
- **low++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement