bsuir.info
БГУИР: Дистанционное и заочное обучение
(файловый архив)
Вход (быстрый)
Регистрация
Категории каталога
Другое [157]
АВС [6]
КПиЯП [80]
ОАиП [305]
ОКТ [79]
СиСПО [8]
Форма входа
Логин:
Пароль:
Поиск
Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0
Файловый архив
Файлы » ПОИТ » ОАиП

Кусовая работа крестики-нолики
Подробности о скачивании 25.11.2009, 06:58
program hrestyky_nulyky;
uses crt;
label
MENU, next_step, hod_0{comp}, hod_1{user};
var
zagolovok_strok, string1, string11, string2, string22, string3, pustaja_setka : string[14];
player, computer, step1, otvet: integer;
k1, k2, k3 ,k4 ,k5, k6, k7, k8, k9, hod_user: boolean;
delay_time:word;
analysing:string;
Begin{1}
k1:=false; k2:=false; k3:=false;
k4:=false; k5:=false; k6:=false;
k7:=false; k8:=false; k9:=false;
zagolovok_strok:=' 1 2 3 ';
pustaja_setka:= ' | | ';
string1:= '1 | | ';
string2:= '2 | | ';
string3:= '3 | | ';
string11:=' ___|___|___ ';
string22:=' ___|___|___ ';
delay_time:=65000;
analysing:='Analysing.';
clrscr;
writeln;
writeln(' Ы Ы ЫЫ ЫЫЫ ЫЫЫ ЫЫЫ Ы Ы Ы Ы Ы Ы');
writeln(' Ы Ы Ы Ы Ы Ы Ы Ы Ы ЫЫ Ы Ы');
writeln(' ЫЫ ЫЫ ЫЫ Ы Ы Ы Ы Ы Ы Ы Ы');
writeln(' Ы Ы Ы Ы Ы Ы ЫЫЫ Ы Ы ЫЫЫ');
writeln(' Ы Ы Ы ЫЫЫ ЫЫЫ Ы Ы Ы Ы Ы Ы Ы');
writeln;
writeln(' Ы Ы ЫЫЫ ЫЫ Ы Ы Ы Ы Ы Ы');
writeln(' Ы Ы Ы Ы Ы Ы Ы Ы ЫЫ Ы Ы');
writeln(' ЫЫЫ Ы Ы Ы Ы Ы Ы Ы Ы Ы Ы');
writeln(' Ы Ы Ы Ы Ы Ы ЫЫЫ Ы Ы ЫЫЫ');
writeln(' Ы Ы ЫЫЫ Ы Ы Ы Ы Ы Ы Ы Ы');
writeln;

MENU:

k1:=false; k2:=false; k3:=false; k4:=false; k5:=false;
k6:=false; k7:=false; k8:=false; k9:=false;
zagolovok_strok:=' 1 2 3 ';
pustaja_setka:= ' | | ';
string1:= '1 | | ';
string2:= '2 | | ';
string3:= '3 | | ';
string11:=' ___|___|___ ';
string22:=' ___|___|___ ';
analysing:='Analysing.';

writeln(' MENU');
writeln('1. Vivod instrukcii');
writeln('2. Nachat igru');
writeln('3. Pro razrabotchika');
writeln('4. Vixod');
writeln;
write('Vibor: ');
read(otvet);
clrscr;
case otvet of
1:
begin{2}
writeln(' .::INSTRUKCIJA::. ');
writeln;
writeln('dlja togo schtobi postavic "X" v reschetku neobxodimo napisat vmeste nomer stroki i nomer stolbca.');
writeln('NAPRIMER: nomer stroki-3, a nomer stolbca-1, to nabiraem - "31"');
writeln;
writeln('nachalnoe pole imeet vid');
writeln;
writeln(zagolovok_strok);
writeln(pustaja_setka);
writeln(string1);
writeln(string11);
writeln(pustaja_setka);
writeln(string2);
writeln(string22);
writeln(pustaja_setka);
writeln(string3);
writeln(pustaja_setka);
writeln;
writeln('Press any key.....');
writeln;
readkey;
clrscr;
string3[4]:='X';
writeln('Mi polychaem v naschem slychae:');
writeln;
writeln(zagolovok_strok);
writeln(pustaja_setka);
writeln(string1);
writeln(string11);
writeln(pustaja_setka);
writeln(string2);
writeln(string22);
writeln(pustaja_setka);
writeln(string3);
writeln(pustaja_setka);
writeln;
writeln('Press any key.....');
writeln;
readkey;
clrscr;
string3:= '3 | | ';
clrscr; goto MENU;
end;{2}
2:
begin{3}
writeln('pervij xod vibiraet slychaj');
write('5 '); delay(delay_time);
write('4 '); delay(delay_time);
write('3 '); delay(delay_time);
write('2 '); delay(delay_time);
writeln('1'); delay(delay_time);
randomize;
step1:=random(2);
if step1=0 then
begin{3.1}
writeln('Pervij xod dastaetsja compjuteru');
hod_0:{comp}
delay(delay_time);
clrscr;
hod_user:=false;
computer:=random(9)+1;
{KONTROL}
writeln(analysing+'.');
{write('Random: ',computer,' ');}
analysing:=analysing+'.';

if (string1[4]='X') and (string1[8]='X') then if k3=false then computer:=3; {k1 k2}
if (string1[4]='X') and (string1[12]='X') then if k2=false then computer:=2; {k1 k3}
if (string1[8]='X') and (string1[12]='X') then if k1=false then computer:=1; {k2 k3}
if (string2[4]='X') and (string2[8]='X') then if k6=false then computer:=6; {k4 k5}
if (string2[4]='X') and (string2[12]='X') then if k5=false then computer:=5; {k4 k6}
if (string2[8]='X') and (string2[12]='X') then if k4=false then computer:=4; {k5 k6}
if (string3[4]='X') and (string3[8]='X') then if k9=false then computer:=9; {k7 k8}
if (string3[4]='X') and (string3[12]='X') then if k8=false then computer:=8; {k7 k9}
if (string3[8]='X') and (string3[12]='X') then if k7=false then computer:=7; {k8 k9}
if (string1[4]='X') and (string2[4]='X') then if k7=false then computer:=7; {k1 k4}
if (string1[4]='X') and (string3[4]='X') then if k4=false then computer:=4; {k1 k7}
if (string2[4]='X') and (string3[4]='X') then if k1=false then computer:=1; {k4 k7}
if (string1[8]='X') and (string2[8]='X') then if k8=false then computer:=8; {k2 k5}
if (string1[8]='X') and (string3[8]='X') then if k5=false then computer:=5; {k2 k8}
if (string2[8]='X') and (string3[8]='X') then if k2=false then computer:=2; {k5 k8}
if (string1[12]='X') and (string2[12]='X') then if k9=false then computer:=9; {k3 k6}
if (string1[12]='X') and (string3[12]='X') then if k6=false then computer:=6; {k3 k9}
if (string2[12]='X') and (string3[12]='X') then if k3=false then computer:=3; {k6 k9}
if (string1[12]='X') and (string2[8]='X') then if k7=false then computer:=7; {k3 k5}
if (string1[12]='X') and (string3[4]='X') then if k5=false then computer:=5; {k3 k7}
if (string2[8]='X') and (string3[4]='X') then if k3=false then computer:=3; {k5 k7}
if (string1[4]='X') and (string2[8]='X') then if k9=false then computer:=9; {k1 k5}
if (string1[4]='X') and (string3[12]='X') then if k5=false then computer:=5; {k1 k9}
if (string2[8]='X') and (string3[12]='X') then if k1=false then computer:=1; {k5 k9}

if (string1[4]='0') and (string1[8]='0') then if k3=false then computer:=3; {k1 k2}
if (string1[4]='0') and (string1[12]='0') then if k2=false then computer:=2; {k1 k3}
if (string1[8]='0') and (string1[12]='0') then if k1=false then computer:=1; {k2 k3}
if (string2[4]='0') and (string2[8]='0') then if k6=false then computer:=6; {k4 k5}
if (string2[4]='0') and (string2[12]='0') then if k5=false then computer:=5; {k4 k6}
if (string2[8]='0') and (string2[12]='0') then if k4=false then computer:=4; {k5 k6}
if (string3[4]='0') and (string3[8]='0') then if k9=false then computer:=9; {k7 k8}
if (string3[4]='0') and (string3[12]='0') then if k8=false then computer:=8; {k7 k9}
if (string3[8]='0') and (string3[12]='0') then if k7=false then computer:=7; {k8 k9}
if (string1[4]='0') and (string2[4]='0') then if k7=false then computer:=7; {k1 k4}
if (string1[4]='0') and (string3[4]='0') then if k4=false then computer:=4; {k1 k7}
if (string2[4]='0') and (string3[4]='0') then if k1=false then computer:=1; {k4 k7}
if (string1[8]='0') and (string2[8]='0') then if k8=false then computer:=8; {k2 k5}
if (string1[8]='0') and (string3[8]='0') then if k5=false then computer:=5; {k2 k8}
if (string2[8]='0') and (string3[8]='0') then if k2=false then computer:=2; {k5 k8}
if (string1[12]='0') and (string2[12]='0') then if k9=false then computer:=9; {k3 k6}
if (string1[12]='0') and (string3[12]='0') then if k6=false then computer:=6; {k3 k9}
if (string2[12]='0') and (string3[12]='0') then if k3=false then computer:=3; {k6 k9}
if (string1[12]='0') and (string2[8]='0') then if k7=false then computer:=7; {k3 k5}
if (string1[12]='0') and (string3[4]='0') then if k5=false then computer:=5; {k3 k7}
if (string2[8]='0') and (string3[4]='0') then if k3=false then computer:=3; {k5 k7}
if (string1[4]='0') and (string2[8]='0') then if k9=false then computer:=9; {k1 k5}
if (string1[4]='0') and (string3[12]='0') then if k5=false then computer:=5; {k1 k9}
if (string2[8]='0') and (string3[12]='0') then if k1=false then computer:=1; {k5 k9}

{KONTROL}
{writeln('Zashita & Nastup: ',computer);}

case computer of
1: if k1=true then goto hod_0;
2: if k2=true then goto hod_0;
3: if k3=true then goto hod_0;
4: if k4=true then goto hod_0;
5: if k5=true then goto hod_0;
6: if k6=true then goto hod_0;
7: if k7=true then goto hod_0;
8: if k8=true then goto hod_0;
9: if k9=true then goto hod_0;
end;{case end}

{KONTROL}
{writeln('Ne pustaja ',computer);}

case computer of
1: begin string1[4]:='0'; k1:=true; end;
2: begin string1[8]:='0'; k2:=true; end;
3: begin string1[12]:='0'; k3:=true; end;
4: begin string2[4]:='0'; k4:=true; end;
5: begin string2[8]:='0'; k5:=true; end;
6: begin string2[12]:='0'; k6:=true; end;
7: begin string3[4]:='0'; k7:=true; end;
8: begin string3[8]:='0'; k8:=true; end;
9: begin string3[12]:='0'; k9:=true; end;
end;{case end}

{KONTROL}
{writeln('Na vyvod ',computer);}

writeln;
writeln(zagolovok_strok);
writeln(pustaja_setka);
writeln(string1);
writeln(string11);
writeln(pustaja_setka);
writeln(string2);
writeln(string22);
writeln(pustaja_setka);
writeln(string3);
writeln(pustaja_setka);
goto next_step;

end{3.1}
else
begin{3.2}
writeln('Pervij xod dastaetsja vam');
hod_1:{user}
delay(delay_time); delay(delay_time);
delay(delay_time); delay(delay_time);
delay(delay_time);
clrscr;
hod_user:=true;
writeln('Vvedite stroky na stalbec: ');
writeln;
writeln(zagolovok_strok);
writeln(pustaja_setka);
writeln(string1);
writeln(string11);
writeln(pustaja_setka);
writeln(string2);
writeln(string22);
writeln(pustaja_setka);
writeln(string3);
writeln(pustaja_setka);
writeln;
write('Koordynaty: ');
read(player);

case player of
11: if k1=true then goto hod_1;
12: if k2=true then goto hod_1;
13: if k3=true then goto hod_1;
21: if k4=true then goto hod_1;
22: if k5=true then goto hod_1;
23: if k6=true then goto hod_1;
31: if k7=true then goto hod_1;
32: if k8=true then goto hod_1;
33: if k9=true then goto hod_1;
else
begin
writeln('Oschibka procht instrukciju!'); goto hod_1; end;
end;{case end}
clrscr;
case player of
11:begin string1[4]:='X'; k1:=true; end;
12:begin string1[8]:='X'; k2:=true; end;
13:begin string1[12]:='X'; k3:=true; end;
21:begin string2[4]:='X'; k4:=true; end;
22:begin string2[8]:='X'; k5:=true; end;
23:begin string2[12]:='X'; k6:=true; end;
31:begin string3[4]:='X'; k7:=true; end;
32:begin string3[8]:='X'; k8:=true; end;
33:begin string3[12]:='X'; k9:=true; end;
end;{case end}

writeln;
writeln;
writeln(zagolovok_strok);
writeln(pustaja_setka);
writeln(string1);
writeln(string11);
writeln(pustaja_setka);
writeln(string2);
writeln(string22);
writeln(pustaja_setka);
writeln(string3);
writeln(pustaja_setka);
goto next_step;

end;{3.2}
end;{3}
3:
begin
writeln(' .::INFORMACIJA O RAZRABOTCHIKE::.');
writeln;
writeln('MELIASHCENIA VALERY');
writeln('data razrabotki 05.11.2009');
writeln('BGYIR, POIT, FNDO');
writeln('e-mail: [email protected]');
writeln;
delay(delay_time);
writeln('Press any key...');
readkey;
clrscr;
goto MENU;
end;
4:
begin{4}
writeln('Spasibo za papitky!');
delay(delay_time);
writeln('Dlja vixoda nagmite Esc');
repeat
if ReadKey = #27 then exit;
until False;

end;{4}
else
begin{5}
writeln('Oschibka, poprobyjte eschche raz');
writeln;
delay(delay_time);
delay(delay_time);
delay(delay_time);
clrscr;
goto MENU;
end;{5}
end;{case end}

next_step:
begin{6}
begin{7}
if (string1[4]='0') and (string1[8]='0') and (string1[12]='0')
then
begin{8}
writeln;
writeln('Первая горизонталь - выиграл COMPUTER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{8}
if (string1[4]='X') and (string1[8]='X') and (string1[12]='X')
then
begin{9}
writeln;
writeln('Первая горизонталь - выиграл GAMER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{9}
if (string2[4]='0') and (string2[8]='0') and (string2[12]='0')
then
begin{10}
writeln;
writeln('Вторая горизонталь - выиграл COMPUTER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{10}
if (string2[4]='X') and (string2[8]='X') and (string2[12]='X')
then
begin{11}
writeln;
writeln('Вторая горизонталь - выиграл GAMER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{11}
if (string3[4]='0') and (string3[8]='0') and (string3[12]='0')
then
begin{12}
writeln;
writeln('Третья горизонталь - выиграл COMPUTER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{12}
if (string3[4]='X') and (string3[8]='X') and (string3[12]='X')
then
begin{13}
writeln;
writeln('Третья горизонталь - выиграл GAMER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{13}
if (string1[4]='0') and (string2[4]='0') and (string3[4]='0')
then
begin{14}
writeln;
writeln('Первая вертикаль - выиграл COMPUTER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{14}
if (string1[4]='X') and (string2[4]='X') and (string3[4]='X')
then
begin{15}
writeln;
writeln('Первая вертикаль - выиграл GAMER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{15}
if (string1[8]='0') and (string2[8]='0') and (string3[8]='0')
then
begin{16}
writeln;
writeln('Вторая вертикаль - выиграл COMPUTER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{16}
if (string1[8]='X') and (string2[8]='X') and (string3[8]='X')
then
begin{16}
writeln;
writeln('Вторая вертикаль - выиграл GAMER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{16}
if (string1[12]='0') and (string2[12]='0') and (string3[12]='0')
then
begin{17}
writeln;
writeln('Третья вертикаль - выиграл COMPUTER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{17}
if (string1[12]='X') and (string2[12]='X') and (string3[12]='X')
then
begin{18}
writeln;
writeln('Третья вертикаль - выиграл GAMER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{18}
if (string1[4]='0') and (string2[8]='0') and (string3[12]='0')
then
begin{19}
writeln;
writeln('Первая диагональ - выиграл COMPUTER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{19}
if (string1[4]='X') and (string2[8]='X') and (string3[12]='X')
then
begin{20}
writeln;
writeln('Первая диагональ - выиграл GAMER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{20}
if (string1[12]='0') and (string2[8]='0') and (string3[4]='0')
then
begin{21}
writeln;
writeln('Вторая диагональ - выиграл COMPUTER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{21}
if (string1[12]='X') and (string2[8]='X') and (string3[4]='X')
then
begin{22}
writeln;
writeln('Вторая диагональ - выиграл GAMER');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end;{22}
end;{7}
{Yakjo poky peremojtsya nema, hodymo dali}
if (k1=true) and (k2=true) and
(k3=true) and (k4=true) and
(k5=true) and (k6=true) and
(k7=true) and (k8=true) and
(k9=true) then
begin{23}
writeln;
writeln('Игра закончена - боевая ничья');
writeln('Для возврата в меню нажмите любую клавишу');
readkey;
clrscr; goto MENU;
end{23}
else
if hod_user=true then goto hod_0 else goto hod_1;
end;{7}

End.{1}

Категория: ОАиП | Добавил: sp
Просмотров: 1045 | Загрузок: 49
Всего комментариев: 0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]