All pastes #2049483 Raw Edit

Something

public text v1 · immutable
#2049483 ·published 2011-04-22 21:28 UTC
rendered paste body
#include <stdio.h>

void swap(int *pA, int *pB) {

	int temp;
	
	temp = *pA;
	*pA = *pB;
	*pB = temp;
}

void sort(int array[]) {

	int a, b, temp;

	for(a = 0; a < 5; a++) {
		for(b = a + 1; b < 5; b++) {
			if(array[a] > array[b]) {
				swap(&array[a], &array[b]);
			}
		}
	}
}


main() {
	void sort(int []);
	void swap(int *, int *);
	int x, input[5];

	printf("enter 5 random numbers seperated by a space: ");
	scanf("%i %i %i %i %i", &input[0], &input[1], &input[2], &input[3], &input[4], &input[5]);
	sort(input);
	printf("The new order is: ");

	for(x = 0; x < 5; x++) {
		printf("%i", input[x]);
			if(x != 4) {
				printf(", ");
			}
	}
	
	printf("\n");
}