BSD 4_1c_2 release
[unix-history] / usr / src / games / cribbage / cards.c
index 0b9a85a..460eb97 100644 (file)
@@ -1,3 +1,5 @@
+static char sccsid[] = "       cards.c 1.1     82/05/12        ";
+
 
 #include       <stdio.h>
 #include       "deck.h"
 
 #include       <stdio.h>
 #include       "deck.h"
@@ -97,29 +99,32 @@ remove( a, d, n )
        for( i = 0; i < n; i++ )  {
            if(  !eq( a, d[i] )  )  d[j++] = d[i];
        }
        for( i = 0; i < n; i++ )  {
            if(  !eq( a, d[i] )  )  d[j++] = d[i];
        }
-       if(  j < n  )  d[j].suit = d[j].rank = EMPTY;
+       if(  j < n  )  d[j].suit = d[j].rank = -1;
 }
 
 
 
 /*
 }
 
 
 
 /*
- * sorthand:
- *     Sort a hand of n cards
+ * sorthand sorts a hand of n cards
  */
  */
-sorthand(h, n)
-register CARD          h[];
-int                    n;
+
+sorthand( h, n )
+
+    CARD               h[];
+    int                        n;
 {
 {
-       register CARD           *cp, *endp;
+       register  int           i, j;
        CARD                    c;
 
        CARD                    c;
 
-       for (endp = &h[n]; h < endp - 1; h++)
-           for (cp = h + 1; cp < endp; cp++)
-               if ((cp->rank < h->rank) ||
-                    (cp->rank == h->rank && cp->suit < h->suit)) {
-                   c = *h;
-                   *h = *cp;
-                   *cp = c;
+       for( i = 0; i < (n - 1); i++ )  {
+           for( j = (i + 1); j < n; j++ )  {
+               if(  ( h[j].rank < h[i].rank )  ||
+                    ( h[j].rank == h[i].rank && h[j].suit < h[i].suit )  )  {
+                   c = h[i];
+                   h[i] = h[j];
+                   h[j] = c;
                }
                }
+           }
+       }
 }
 
 }