主题:数字游戏[3]
QQ331373582
[专家分:1500] 发布于 2005-08-05 10:57:00
魔术师翻牌,魔术师将扑克中的13张黑桃预先排好,牌面朝下,放在手中,第一次数一张牌翻过来刚刚好是A,放在桌面上,第二次数两张牌,数一的那张,放在手中牌的下面数2的牌,翻过来刚刚好是2,放在桌面上,第三次数三张牌,数一和二的那张,放在手中牌的下面,数3的牌,翻过来刚刚好是3,仍然放桌面上。这样做下去,直到13张牌翻圆为止,此时桌面上的牌顺序刚刚好是A,2,3,4,5,6,7,8,9,10,J,Q,K。请编程找出魔术师手中的13张牌的原始顺序...
回复列表 (共3个回复)
沙发
kuuga [专家分:190] 发布于 2005-08-06 09:36:00
const t:array[1..13]of string
=('A','2','3','4','5','6','7','8','9','10','J','Q','K');
var s,s1,s2,s4:string;
a,c,z,as:longint;
begin
a:=0;
s1:='';
s2:='';
s:='123456789tjqk';
repeat
if length(s)<=a then begin
inc(a);as:=a;as:=as mod length(s);
if as=0 then as:=length(s);
as:=as-1;inc(as);s2:=s2+s[as];
for c:=1 to as-1 do s1:=s1+s[c];
delete(s,1,as);s:=s+s1;s1:='';
end else if length(s)>a then begin
inc(a);s2:=s2+s[a];
for c:=1 to a-1 do s1:=s1+s[c];
delete(s,1,a);s:=s+s1;s1:='';
end;
until length(s)=0;
write('The first position of those poker carks are ');
for z:=1 to 13 do begin
for c:=1 to 13 do begin
str(z,s4);
if z=13 then s4:='k' else if z=12 then s4:='q' else if z=11 then s4:='j' else
if z=10 then s4:='t';
if s2[c]=s4 then begin
write(t[c],' ');
end;
end;
end;
write('.');
end.
板凳
口口and枕头 [专家分:1550] 发布于 2005-08-06 17:43:00
能解释一下吗?
3 楼
kuuga [专家分:190] 发布于 2005-08-07 11:03:00
#$!^%&^!@&*^%*&()&*(^*@)*&^#*()&(_@*%(%_@(%@+_%(*%&()@#&%#*($^^%*@&$*(^@$(~#$$%$#&^$%*(&^#&^)&^*&*(#)(_|+$(%(#_|%)@|)^|^)|@)%|^)|)|^|^%$&&*^&()&&*......................................................................................................................................................................................................................................................... Do you understand?????????????
我来回复