Pagini recente » Cod sursa (job #93947) | Cod sursa (job #2980676) | Cod sursa (job #1389497) | Cod sursa (job #2144284) | Cod sursa (job #872737)
Cod sursa(job #872737)
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
int a[10000];
int main()
{long long n,i,j,h,k;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
f>>n;
k=0;
for(i=1;i<=n;i++)f>>a[i];
sort(a+1,a+n+1);
for(i=1;i<n-1;i++)
for(j=i+1;j<n;j++)
for(h=j+1;h<=n;h++)
if(a[i]+a[j]>=a[h] && a[j]+a[h]>=a[i] && a[h]+a[i]>=a[j])k++;
else break;
g<<k;}