主题:[原创][下载]自动化发牌(52张标准扑克)程序
PASCAL (PREE PASCAL or TRUBO PASCAL)
Const
d:string[4] = '3456';
Type
atype = record
style:char;
pip:byte;
end;
Var
a:array [1..52] of atype;
b:array[1..4,1..13] of boolean;
i,j,x,y,z,w:integer;
Begin
randomize;
fillchar(b,sizeof(b),true);
for i:=1 to 52 do begin
repeat
x:=random(4)+1;
y:=random(13)+1;
until b[x,y];
b[x,y]:=false;
a[i].style:=d[x];
a[i].pip:=y;
end;
for i:=1 to 4 do begin
write('No.',i,' :');
j:=i;
repeat
val(a[j].style,z,w);
write(chr(z),a[j].pip,' ');
j:=j+4;
until j>52;
writeln;
end;
writeln;
readln;
End.
Const
d:string[4] = '3456';
Type
atype = record
style:char;
pip:byte;
end;
Var
a:array [1..52] of atype;
b:array[1..4,1..13] of boolean;
i,j,x,y,z,w:integer;
Begin
randomize;
fillchar(b,sizeof(b),true);
for i:=1 to 52 do begin
repeat
x:=random(4)+1;
y:=random(13)+1;
until b[x,y];
b[x,y]:=false;
a[i].style:=d[x];
a[i].pip:=y;
end;
for i:=1 to 4 do begin
write('No.',i,' :');
j:=i;
repeat
val(a[j].style,z,w);
write(chr(z),a[j].pip,' ');
j:=j+4;
until j>52;
writeln;
end;
writeln;
readln;
End.