编程高手来看看这道题

2024-12-13 02:28:35
推荐回答(2个)
回答1:

每次必须同时移动相邻的两个棋子,颜色不限,可以左移也可以右移。移动时,必须跳过若干个棋子.
那同时移动2个白圈,移动2次不就成了?(不知题目是这意思不?)
program tu;
var a:array[1..60] of char;
i,n,x,y:integer;
procedure change(j,k:integer);
var p:integer;q:char;
begin
q:=a[j];
for p:=j to k-1 do
a[p]:=a[p+1];
a[k]:=q;
end;

begin
readln(n);
for i:=1 to n do a[i]:='o';
for i:=n+1 to 2*n do a[i]:='*';
x:=n; y:=2*n-1;
repeat
change(x,y);
x:=x-1; y:=y-2;
until x=1;
for i:=1 to 2*n do write(a[i]);
end.
运行时,输入N,回车就有解了N<=30

回答2:

ZHEG WE\FLPS RTEDS R HYJ AF ASC RG F MFOIAR J JAOI R9 MFIDL M
hrio nso ;jmsfoij mg odsl afjm jfopr m0 fdma fm9dso
NU9FIMS NUJMF WTK MP -0[ JFSP irk op
hujrl jf kjf0-wpf mv -0s