Pagini recente » Cod sursa (job #2468032) | Cod sursa (job #603046) | Cod sursa (job #658259) | Cod sursa (job #659417) | Cod sursa (job #1131854)
Program triunghiuri;
var V : array [1..900] of longint;
n,i,l,j,m : longint;
procedure swap ( var x,y : longint);
var aux : longint;
begin
aux:=x;
x:=y;
y:=aux;
end;
begin
assign(input,'nrtri.in'); reset(input);
assign(output,'nrtri.out'); rewrite(output);
readln(n); l:=0;
for i:=1 to n do read(V[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if V[i]>V[j] then swap(V[i],V[j]);
for i:=1 to n-2 do
for j:=i+1 to n-1 do begin
m:=j+1;
while (V[m]<=(V[i]+V[j])) and (m<=n) do begin
l:=l+1;
m:=m+1;
end;
end;
writeln(l);
close(input); close(output);
end.