All pastes #77789 Raw Edit

Mine

public c v1 · immutable
·published 2006-07-03 11:41 UTC
rendered paste body
#include <stdio.h>#include "genlib.h" #include "simpio.h"#define size 7 void sortArray (int numbers[]); int indexMax (int numbers[], int low, int high);void swap (int numbers[], int loc1, int loc2);void getArray (int numbers[]);void displayArray (int numbers[]);main(){	int numbers[size];	getArray(numbers);	sortArray(numbers ); 	displayArray (numbers); }void getArray (int numbers[]){	int i;	for (i=0; i<size; i++)	{		printf ("\nEnter next integer? ");		numbers[i]=GetInteger();	}}void displayArray (int numbers[]){	int i;	printf ("\n The sorted list is: \n");	for (i=0; i< size; i++)	{ printf (" %d ", numbers[i]); }}void sortArray (int numbers[]){	int i , maxInd;	for (i=size-1;i>0;i--)	{		maxInd = indexMax (numbers, 0, i);		swap (numbers, i, maxInd);	}}int indexMax (int numbers[], int low, int high){	int i, maxInd;	maxInd=high;	for (i=high;i>=low;i--)	{		if (numbers[i] > numbers[maxInd])			maxInd =i;	}	printf("Largest value between %d and %d is %d.", low, high, maxInd);	return (maxInd);}void swap (int numbers[], int loc1, int loc2){	int temp;	temp=numbers[loc1];	numbers[loc1]=numbers[loc2];	numbers[loc2] = temp;}