不是VIP会员,不能显示答案

题目解答

题目:
program nbcz09_3;
var p:array[1..10000]of longint;
n,i,x:longint;

function find(x:longint):longint;
begin
if p[x]=x then find:=x
else begin
p[x]:=find(p[x]);
find:=p[x];
end;
end;

begin
readln(n,x);
for i:=1 to n do read(p[i]);
writeln(find(x));
for i:=1 to n-1 do write(p[i],' '); //两数之间输出一个空格
writeln(p[n]);
end.
输入5 5
3 3 3 2 4
输出:3
3 3 3 3 3
考点:
分析:
解答:
评论:
老师: