Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::cout;
- void sort(int a[], int nArray)
- {
- int *nechet = new int[nArray];
- int *chet = new int[nArray];
- int i;
- int countChet = 0;
- int countNechet = 0;
- for (i = 0; i < nArray; ++i)
- {
- if (a[i] % 2 > 0)
- {
- nechet[countNechet] = a[i];
- ++countNechet;
- }
- else
- {
- chet[countChet] = a[i];
- ++countChet;
- }
- }
- cout << "Your new array: ";
- for (i = 0; i < countChet; ++i)
- {
- cout << chet[i] << " ";
- }
- for (i = 0; i < countNechet; ++i)
- {
- cout << nechet[i] << " ";
- }
- delete[] chet;
- delete[] nechet;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement