主题:[讨论]两道看似简单的程序填空
先来一道
扑克牌问题,取所有方块(13张),按一定顺序排好,再按要求取牌:上面一张放在旁边,上面一张放到牌堆底部,重复过程,直到翻完最后一张
const cards:string[13]='0123456789 JQK';
var link,take:array[0..13]of 1..13;
precedent,current,i,k:byte;
procedure print(i:byte);
begin if i=( 1 ) then write('10');
else write(cards[i]);
end;
begin
for i:=( 2 ) to 12 do link[i]:=i+1;
link[13]:=( 3 );
for i:=1 to 12 do
begin
current:=( 4 );take[current]:=( 5 );
precedent:=link[precedent];
end;
take[precedent]:=( 6 );
write('lastcard:');print(precedent);writeln;
for i:=1 to 13 do print( 7 );
writeln;readln
end.
扑克牌问题,取所有方块(13张),按一定顺序排好,再按要求取牌:上面一张放在旁边,上面一张放到牌堆底部,重复过程,直到翻完最后一张
const cards:string[13]='0123456789 JQK';
var link,take:array[0..13]of 1..13;
precedent,current,i,k:byte;
procedure print(i:byte);
begin if i=( 1 ) then write('10');
else write(cards[i]);
end;
begin
for i:=( 2 ) to 12 do link[i]:=i+1;
link[13]:=( 3 );
for i:=1 to 12 do
begin
current:=( 4 );take[current]:=( 5 );
precedent:=link[precedent];
end;
take[precedent]:=( 6 );
write('lastcard:');print(precedent);writeln;
for i:=1 to 13 do print( 7 );
writeln;readln
end.