Pagini recente » Cod sursa (job #1188991) | Cod sursa (job #2280145) | Cod sursa (job #1335779) | Cod sursa (job #658542) | Cod sursa (job #1131838)
Program triunghiuri;
var V : array [1..900] of longint;
n,i,l,j,k : 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
for k:=j+1 to n do
if (V[k]<=V[j]+V[i]) and (V[k]>=V[j]-V[i])
then l:=l+1;
writeln(l);
close(input); close(output);
end.