10 numeros aleatorios en pascal sin repeticion
Publicado por AndRea Camila (1 intervención) el 31/10/2021 14:23:34
Buen dia, necesito hacer un codigo que me genere 10 numeros al azar sin repeticion, es decir, que me coloque numeros del 0 al 9 en cualquier orden, pero que no se repitan, además no puedo utilizar array
randomize;
s1:='';
for i:=1 to 10 do
begin
x1:=random(10);
str(x1,yaux);
s1:=s1+yaux;
m:=length(s1);
for i:=1 to m do
begin
if (yaux<>s1[i]) then
begin
str(x1,yaux);
s1:=s1+yaux;
m:=length(s1);
end
else
begin
repeat
x1:=random(10);
str(x1,yaux);
m:=length(s1);
until (yaux<>s1[i]);
end;
end;
end;
write(s1);
readkey;
si alguien me pudiera ayyudar, se lo agradecería, porque mi codigo programado no parece leerlo correctamente
randomize;
s1:='';
for i:=1 to 10 do
begin
x1:=random(10);
str(x1,yaux);
s1:=s1+yaux;
m:=length(s1);
for i:=1 to m do
begin
if (yaux<>s1[i]) then
begin
str(x1,yaux);
s1:=s1+yaux;
m:=length(s1);
end
else
begin
repeat
x1:=random(10);
str(x1,yaux);
m:=length(s1);
until (yaux<>s1[i]);
end;
end;
end;
write(s1);
readkey;
si alguien me pudiera ayyudar, se lo agradecería, porque mi codigo programado no parece leerlo correctamente
Valora esta pregunta


0