Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void print_numbers(char *str)
- {
- assert(str);
- while (auto pos = strpbrk(str, "0123456789")) {
- auto len = strspn(pos, "0123456789");
- print(pos, pos + len - 1);
- str = pos + len;
- }
- std::cout << std::endl;
- }
- void swap_min_max(double *arr, int n)
- {
- assert(arr);
- auto min = arr, max = arr;
- for (auto i = 0; i < n; ++i) {
- if (*(arr + i) < *min) min = arr + i;
- if (*(arr + i) > *max) max = arr + i;
- }
- auto temp = *min;
- *min = *max;
- *max = temp;
- }
- void swap_halves(int *arr, int n)
- {
- assert(arr);
- assert(n % 2 == 0);
- for (int i = 0; i < n / 2; ++i) {
- std::swap(*(arr + n / 2 + i), *(arr + i));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement