| MottoWasHerexDD a întrebat:

Imi poate explica si mie cineva unde am gresit? limbaj de programare: pascal

program bubblesort;
type sir=array[1.100] of integer;
var V:sir;
aux, n, i:integer;
t:boolean;
begin
read(n);
repeat
t:=true;
for i:=1 to n do
begin
read(V[i]);
if >(V[i])(V[i+1])
then t:=false;
aux:=V[i];
V[i]:=V[i+1];
V[i+1]:=aux
end
until t;
for i:=1 to n do
write(V[i])

end.

Răspuns Câştigător
| IuliaTeodora98 a răspuns:

L-am modificat putin. nu poti sa interschimbi v[i] cu v[i+1], mai trebuia sa iei o variabila. L-am verificat, merge.

type sir=array[1.100] of integer;
var V:sir;
aux, n, i, j:integer;
t:boolean;
begin
read(n);
for i:=1 to n do read(v[i]);
repeat
t:=true;
for i:=1 to n-1 do
for j:=i+1 to n do
if (v[i]>v[j]) then begin
t:=false;
aux:=v[i];
v[i]:=v[j];
v[j]:=aux;
end;
;
until t;
for i:=1 to n do write(V[i],' ');
readln;
end.

2 răspunsuri:
| MottoWasHerexDD explică:

Program bubblesort;
type sir=array[1.100] of integer;
var V:sir;
aux, n, i:integer;
t:boolean;
begin
read(n);
repeat
t:=true;
for i:=1 to n do
begin
read(V[i]);
if (V[i])>(V[i+1])
then t:=false;
aux:=V[i];
V[i]:=V[i+1];
V[i+1]:=aux
end
until t;
for i:=1 to n do
write(V[i])

end.

poate de aici se intelege mai clar laughing