home *** CD-ROM | disk | FTP | other *** search
- /* Functions to sort X, Y, and Z arrays Z within Y within X
- * Written by Ron Andrews 6-MAR-88 for demonstration purposes
- */
-
- extern int x[],y[],z[];
- static int xhold,yhold,zhold;
-
- /* load the temporary variables
- */
-
- load(i)
- register i;
- {
- xhold = x[i];
- yhold = y[i];
- zhold = z[i];
- }
-
- /* check the variables against the temporary variable
- */
-
- check(i)
- register i;
- {
- if (xhold < x[i])
- return(-1);
- if (xhold > x[i])
- return(1);
- if (yhold < y[i])
- return(-1);
- if (yhold > y[i])
- return(1);
- if (zhold < z[i])
- return(-1);
- return(zhold > z[i]);
- }
-
- /* swap the variables
- */
-
- swap(i,j)
- register i,j;
- {
- static int t;
- t = x[i];
- x[i] = x[j];
- x[j] = t;
- t = y[i];
- y[i] = y[j];
- y[j] = t;
- t = z[i];
- z[i] = z[j];
- z[j] = t;
- }