Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void sortInt();
- int main(void) {
- signed int numbers[5] = {10, 7, -5, 6, 1};
- printf("Before: ");
- int i;
- int* n = numbers;
- for (i = 0; i < 5; i++)
- printf("%d, ", *n++);
- sortInt(numbers);
- printf("\nAfter: ");
- n = numbers;
- for (i = 0; i < 5; i++)
- printf("%d, ", *n++);
- }
- void sortInt(signed int *numbers) {
- int top = 0;
- int temp = 0;
- while (top <= sizeof(numbers)) {
- while (top > 0 && *numbers < *(numbers - 1)) {
- temp = *numbers;
- *numbers = *(numbers - 1);
- *(numbers - 1) = temp;
- top--;
- numbers--;
- }
- top++;
- numbers++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement