projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BSD 3 development
[unix-history]
/
usr
/
src
/
games
/
arithmetic.c
diff --git
a/usr/src/games/arithmetic.c
b/usr/src/games/arithmetic.c
index
df6f707
..
f369918
100644
(file)
--- a/
usr/src/games/arithmetic.c
+++ b/
usr/src/games/arithmetic.c
@@
-1,5
+1,5
@@
+#include <stdio.h>
#include <signal.h>
#include <signal.h>
-
#define MAX 100
char types[10];
#define MAX 100
char types[10];
@@
-17,6
+17,7
@@
char *argv[];
int range, k, dif, l;
char line[100];
int ans,pans,i,j,t;
int range, k, dif, l;
char line[100];
int ans,pans,i,j,t;
+ char dir,sense;
extern delete();
signal(SIGINT, delete);
extern delete();
signal(SIGINT, delete);
@@
-41,7
+42,7
@@
char *argv[];
}
if(range > MAX) {
printf("Range is too large.\n");
}
if(range > MAX) {
printf("Range is too large.\n");
- exit(
0
);
+ exit();
}
if(dif == 0) {
}
if(dif == 0) {
@@
-128,10
+129,10
@@
char *s;
while((*rs = getchar()) == ' ');
while(*rs != '\n')
if(*rs == 0)
while((*rs = getchar()) == ' ');
while(*rs != '\n')
if(*rs == 0)
- exit(
0
);
+ exit();
else if(rs >= &s[99]) {
while((*rs = getchar()) != '\n')
else if(rs >= &s[99]) {
while((*rs = getchar()) != '\n')
- if(*rs == '\0') exit(
0
);
+ if(*rs == '\0') exit();
}
else
*++rs = getchar();
}
else
*++rs = getchar();
@@
-152,19
+153,38
@@
char *s;
return(a);
}
return(a);
}
+int arand;
+
+srand(n)
+{
+ arand = n&077774 | 01;
+}
+
+rand() /*uniform on 0 to 2**13-1*/
+{
+
+ arand *= 3125;
+ arand &= 077777;
+ return(arand/4);
+}
random(range)
{
random(range)
{
- return(
rand()%range
);
+ return(
hmul(rand(), 8*range)
);
}
skrand(range){
int temp;
}
skrand(range){
int temp;
- temp = rand
om(range) + random(range
);
- if(temp >
range - 1) temp = 2*range - 1
- temp;
- return(
temp
);
+ temp = rand
() + rand(
);
+ if(temp >
017777) temp = 040000
- temp;
+ return(
hmul(temp,8*range)
);
}
}
+/* 'hmul' returns the upper 16 bits of the product, where the operands
+ are assumed to be 16-bit integers. It replaces an old PDP-11
+ assembler language subroutine. -- dks.
+*/
+hmul(a,b) { return(a*b >> 16); }
score()
{
time(&etvec);
score()
{
time(&etvec);
@@
-180,14
+200,16
@@
score()
sleep(3);
time(&dtvec);
stvec += dtvec - etvec;
sleep(3);
time(&dtvec);
stvec += dtvec - etvec;
+ return(0);
}
delete()
{
if(rights + wrongs == 0.) {
printf("\n");
}
delete()
{
if(rights + wrongs == 0.) {
printf("\n");
- exit(
0
);
+ exit();
}
score();
}
score();
- exit(
0
);
+ exit();
}
}
+