求编
pascal吧
全部回复
仅看楼主
level 3
钨盆 楼主
有47人。
35号不在,然后随机两人一组,不能有人重复
而且22号要和4号一起
2014年12月19日 13点12分 1
level 3
钨盆 楼主
求私
2014年12月19日 13点12分 2
level 11

var
a:array[1..47]of longint;
x,i,y:longint;
f:boolean;
function check:boolean;
var
i:longint;
begin
check:=true;
for i:=1 to 47 do
if a[i]=0 then exit(false);
end;
begin
a[35]:=1;a[4]:=1;a[22]:=1;
randomize;f:=false;
while check=false do
begin
y:=random(10)+1;
if (y=2)and(f=false) then begin f:=true;writeln('4 22');end;
for i:=1 to 2 do
begin
repeat
x:=random(47)+1;
until a[x]=0;
write(x,' ');
a[x]:=1;
end;
writeln;
end;
end.
2014年12月19日 15点12分 3
为什么4 22不会输出
2014年12月20日 11点12分
level 9
Var
 a:array[1..47]of longint;
 i,x:longint;
Begin
 randomize;
 a[4]:=22;a[22]:=-1;a[35]:=-1;
 for i:=1 to 47 do
  if a[i]=0 then
  begin
   repeat
    x:=random(47)+1;
   until(x<>i)and(a[x]=0);
   a[i]:=x;a[x]:=-1;
  end;
 for i:=1 to 47 do
  if a[i]>0 then writeln(i,' ',a[i]);
 readln;
End.
2014年12月20日 14点12分 4
1