diff options
Diffstat (limited to 'snake/snscore/snscore.c')
-rw-r--r-- | snake/snscore/snscore.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/snake/snscore/snscore.c b/snake/snscore/snscore.c index 6b8c2e4e..8ad6b59a 100644 --- a/snake/snscore/snscore.c +++ b/snake/snscore/snscore.c @@ -1,6 +1,8 @@ +/* $NetBSD: snscore.c,v 1.4 1995/04/22 08:34:43 cgd Exp $ */ + /* - * Copyright (c) 1980 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,14 +34,17 @@ */ #ifndef lint -char copyright[] = -"@(#) Copyright (c) 1980 Regents of the University of California.\n\ - All rights reserved.\n"; +static char copyright[] = +"@(#) Copyright (c) 1980, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -/*static char sccsid[] = "from: @(#)snscore.c 5.7 (Berkeley) 2/28/91";*/ -static char rcsid[] = "$Id: snscore.c,v 1.3 1994/04/05 00:42:49 cgd Exp $"; +#if 0 +static char sccsid[] = "@(#)snscore.c 8.1 (Berkeley) 7/19/93"; +#else +static char rcsid[] = "$NetBSD: snscore.c,v 1.4 1995/04/22 08:34:43 cgd Exp $"; +#endif #endif /* not lint */ #include <sys/types.h> @@ -57,9 +62,9 @@ struct player { char *name; } players[MAXPLAYERS], temp; +int main() { - char buf[80], cp; short uid, score; FILE *fd; int noplayers; @@ -77,7 +82,7 @@ main() fread(&whoallbest, sizeof(short), 1, fd); fread(&allbest, sizeof(short), 1, fd); noplayers = 0; - for (uid=2;;uid++) { + for (uid = 2; ;uid++) { if(fread(&score, sizeof(short), 1, fd) == 0) break; if (score > 0) { @@ -91,29 +96,29 @@ main() if (p == NULL) continue; q = p -> pw_name; - players[noplayers].name = malloc(strlen(q)+1); + players[noplayers].name = malloc(strlen(q) + 1); strcpy(players[noplayers].name, q); noplayers++; } } /* bubble sort scores */ - for (notsorted=1; notsorted; ) { + for (notsorted = 1; notsorted; ) { notsorted = 0; - for (i=0; i<noplayers-1; i++) - if (players[i].scores < players[i+1].scores) { + for (i = 0; i < noplayers - 1; i++) + if (players[i].scores < players[i + 1].scores) { temp = players[i]; - players[i] = players[i+1]; - players[i+1] = temp; + players[i] = players[i + 1]; + players[i + 1] = temp; notsorted++; } } j = 1; - for (i=0; i<noplayers; i++) { + for (i = 0; i < noplayers; i++) { printf("%d:\t$%d\t%s\n", j, players[i].scores, players[i].name); - if (players[i].scores > players[i+1].scores) - j = i+2; + if (players[i].scores > players[i + 1].scores) + j = i + 2; } exit(0); } |