Условие задачи:
![](http://upload.akusherstvo.ru/thumbs/741458.jpg)
Решение на Паскале:
Program Game;
type
playtype = ‘0’..'9';
seedtype = 0..65535;
scoretype = 0..4;
var
pool, target: set of playtype;
a, b, c, d: playtype;
seed: seedtype;
bulls, cows: scoretype;
function random: real;
begin
random := seed / 65536;
seed := (25173 * seed + 13849) mod 65536;
end;
function unique: playtype;
var ch: char;
begin
repeat
ch := chr(trunc(10 * random) + ord('0'));
until ch in pool;
unique := ch;
pool := pool - ;
target := target + ;
end;
procedure try(thisone: char);
var ch: char;
begin
read(ch);
if ch in target then
if ch = thisone then
bulls := succ(bulls)
else
cows := succ(cows)
end;
begin
write('Загадайте случайное число, ‘);
writeln(’затем отгадывайте');
readln(seed);
pool := ;
target := ;
a := unique; b := unique; c := unique; d := unique;
repeat
bulls := 0; cows := 0;
try(a); try(b); try©; try(d);
writeln('Быков: ‘, bulls:1, ’; коров: ', cows:1);
readln
until bulls = 4;
readln
end.