//2-D Selection Sort By Using Pointers
#include<stdio.h>									
#include<conio.h>
#define Col 4
#define Row 3
#define SIZE Row*Col

void S(int *);

void main()
{
	int i, j;
	clrscr();
	int array[Row][Col]={
				{-22, 21, -80, 17},
				{46,  -28, 15, -94},
				{-35, 72, -11, -80}
			    };

	S(&array[0][0]);
		printf("\n\tAfter Function Call\n\t");
			for(i=0; i<Row; i++)
				for(j=0; j<Col; j++)
					printf("   %d", array[i][j]);
}


void S(int *ptr)
{
	int m, n, temp;
		for(m=0; m<SIZE; m++)
			for(n=m; n<SIZE-1; n++)
				if( *(ptr+m) < *(ptr+n+1) )
					{
					temp = *(ptr+m);
					*(ptr+m) = *(ptr+n+1);
					*(ptr+n+1) = temp;
					}
		printf("\n\tArray\n\t");

	for(m=0; m<SIZE; m++)
		printf("   %d", *(ptr+m));
}
