EasyManuals Logo

Sinclair QL User Manual

Sinclair QL
422 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #101 background imageLoading...
Page #101 background image
1.
4.
•
•
•
SELect
ON
num
ON num
~
list
of values
statements
ON num
~
list
of values
statements
ON num
~
REMAINDER
statements
END SELect
where num
IS
any numeric variable and the REMAINDER clause
is
optional.
There
IS
a short torm of the SELect structure.
For
example
100
INPUT
num
110
SElect
ON
num
=0
TO
9:
PRINT
"digit"
will
perform
as
you
would expect
Store
10
numbers
in
an
array
and pertorm a 'bubble-sort:
This
IS
done
by
comparing
the first pair and exchanging,
If
necessary, the second pair (second and third
numbers), up
to
the ninth pair (ninth and
tenth
numbers) The first run of nine
comparisons and possible exchanges guarantees that the highest number
will
reach
ItS
correct position Another eight runs
will
guarantee eight more correct positions
leaving only the lowest number which must be
In
the only (correct) position
left.
The simplest form of 'bubble sort' of
ten
numbers requires nine runs of nine
comparisons.
2.
Consider
ways
of speeding up bubblesort, but
do
not expect that
It
will
ever be
very efficient
3.
An auctioneer wishes
to
sell
an old clock and he has instructions
to
invite a
first
bid of
£50.
If
no-one bids
he
can come down
to
£40, £30, £20,
but no lower
in
an effort
to
start the bidding.
If
no-one bids, the clock
is
withdrawn from the
sale.
When the bidding
starts,
he takes only
£5
Increases until the final bid
is
made.
If
the final bid
is
£35 (the 'reserve price) or more, the clock
is
sold. Otherwise
It
IS
withdrawn.
Simulate the auction using
the
equivalent of a six-sided die throw
to
start
the
bidding.
A 'six'
at
any of the starting prices
will
start
it
off.
When the bidding has started there should be a three out of four chance of a
higher bid
at
each invitation.
In
a wild west shoot-out the Sheriff has no ammunition and wishes
to
arrest a
gunman camped
In
a forest He rides amongst the trees tempting the gunman
to
fire.
He hopes that when six shots have been fired he can rush
in
and overpower
the gunman
as
he tries
to
re-Ioad. Simulate the encounter giving the gunman a
one-twentieth chance
of
hitting the Sheriff with each shot
If
the Sheriff has not
been hit after
SIX
shots
he
will
arrest the gunman.
5.
The Sheriff's Instructions
to
his Deputy
are:
"If
the gun
is
empty then re-Ioad
it
and
if
it
ain't then keep on firing
until
you
hit the bandit or he surrenders.
If
MexIco
Pete
turns
up,
get out
fast:'
Write a program which caters properly for
all
these situations:
Whatever happens, return
to
Dodge
City.
If
MexIco
Pete
turns
up,
return immediately.
If
the gun
is
empty, reload it
If
the gun
is
not empty, ask the bandit
to
surrender
If
the bandit surrenders, arrest him.
If
he doesn't surrender,
fire
a shot
If
the bandit
is
hit,
arrest him and
fiX
hiS
wound.
Assume an unlimited supply
of
ammunition. Use a simulated 'twenty-sided die'
and let a
seven
mean 'surrender' and a 'thirteen' mean the bandit
IS
hit
12/84
LONG FORM
SHORT FORM
PROBLEMS
ON
CHAPTER
14
85

Other manuals for Sinclair QL

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair QL and is the answer not in the manual?

Sinclair QL Specifications

General IconGeneral
ProcessorMotorola 68008
Clock Speed7.5 MHz
RAM128 KB (expandable to 640 KB)
ROM48 KB
Operating SystemSinclair QDOS
Release Year1984
StorageMicrodrive tape loop
Graphics256x256 pixels, 8 colors
PortsRS-232, ROM cartridge
SoundBeeper (internal speaker)

Related product manuals