超新手!!! 发布井字棋游戏,bug勿吐槽!
pascal吧
全部回复
仅看楼主
level 9
@猎火电脑工作室
欢迎指教。bug有点多,电脑有点傻,等以后学得多了再优化。二楼发源代码。
2015年02月13日 06点02分 1
level 9
http://yunpan.cn/cKaVHe8mRLrRw 访问密码 d8cb
2015年02月13日 06点02分 3
level 9
var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,t:longint;
s:array[1..3,1..3] of longint;
q:boolean;
begin
writeln('欢迎来到井字棋的世界');
writeln('游戏规则:');
writeln('1.“0”代表还没有棋在那;2.请按坐标轴的格式输入下的棋的位置。如1 2,再按回车;3."1"代表此处您已下棋,"2"代表此处电脑已下棋.');
for a:=1 to 3 do
begin
for b:=1 to 3 do write(s[a,b],' ');
writeln
end;
writeln('请输入您的棋招,请按x y格式输入');
repeat
readln(d,c);
if (c>3)or(c<0)or(d>3)or(d<0)or(s[c,d]<>0)then
begin
repeat
writeln('违规输入,请重输');
readln(d,c);
until (c<=3)and(d<=3)and(d>=0)and(c>=0)and(s[c,d]=0);
end;writeln;
s[c,d]:=1;
for a:=1 to 3 do
begin
for b:=1 to 3 do
begin
if s[a,b]=1 then inc(e);
if e=3 then
begin
writeln('你赢了');
inc(f);
end;
end;
e:=0;
for b:=1 to 3 do
begin
if s[b,a]=1 then inc(e);
if e=3 then
begin
writeln('你赢了');
inc(f);
end;
end;
e:=0;
if (s[1,1]=1)and(s[2,2]=1)and(s[3,3]=1) then
begin
writeln('你赢了');
inc(f);
end;
if (s[1,3]=1)and(s[2,2]=1)and(s[3,1]=1) then
begin
writeln('你赢了');
inc(f);
end;
end;
while (f=0) and (g=0) do
begin
for a:=1 to 3 do
begin
for b:=1 to 3 do
begin
if s[a,b]=2 then inc(h);
if (h=2)and(g=0) then
begin
if s[a,b]=0 then
begin
s[a,b]:=2;
inc(g);
end;
end;
end;
h:=0;
for r:=1 to 3 do
begin
for t:=1 to 3 do
begin
if s[r,t]=1 then inc(j);
if (j=2)and(g=0) then
begin
for n:=1 to 3 do
begin
if s[r,n]=0 then
begin
s[r,n]:=2;
inc(g);
end;
end;
end;
end;end;
j:=0;
end;
if (s[2,2]=0)and(g=0) then
begin
s[2,2]:=2;
inc(g);
end;
if (g=0) and(s[4-c,4-d]=0) then
begin
s[4-c,4-d]:=2;
inc(g);
end;
if g=0 then
begin
for a:=1 to 3 do
for b:=1 to 3 do
while j=0 do
begin
if s[a,b]=0 then inc(j);
s[a,b]:=2;
inc(g);
end;
end;
end;
g:=0;j:=0;
for m:=1 to 3 do
begin
for n:=1 to 3 do
begin;
if s[m,n]=2 then inc(l);
if l=3 then
begin
writeln('你输了');
inc(f);
end;
end;
l:=0;
for n:=1 to 3 do
begin;
if s[n,m]=2 then inc(l);
if l=3 then
begin
writeln('你输了');
inc(f);
end;
end;
l:=0;
if (s[1,1]=2)and(s[2,2]=2)and(s[3,3]=2) then
begin
writeln('你输了');
inc(f);
end;
if (s[1,3]=2)and(s[2,2]=2)and(s[3,1]=2) then
begin
writeln('你输了');
inc(f);
end;
end;
for a:=1 to 3 do
begin
for b:=1 to 3 do write(s[a,b],' ');
writeln;
end;
inc(o);writeln;
until (o=4) or (f<>0);
if (o=4)and(f=0) then writeln('平局');
readln;
end.
2015年02月13日 06点02分 4
level 7
orz大神
2015年02月13日 08点02分 7
level 9
顶一个
2015年02月13日 09点02分 9
1