Pagini recente » Cod sursa (job #2595968) | Cod sursa (job #2436564) | Cod sursa (job #2436566) | Cod sursa (job #996735) | Cod sursa (job #709863)
Cod sursa(job #709863)
#include <fstream>
using namespace std;
fstream fin("nrtri.in",ios::in),fout("nrtri.out",ios::out);
int main()
{
int n,i,j,k,cate=0,ok;
long long a[30001],aux;
fin>>n;
for (i=1;i<=n;i++)
{
fin>>a[i];
}
do
{
ok=1;
for (i=1;i<n;i++)
{
if (a[i]>a[i+1])
{
aux=a[i];
a[i]=a[i+1];
a[i+1]=aux;
ok=0;
}
}
}while (ok==0);
for (i=1;i<=n;i++)
{
for (j=i+1;j<=n;j++)
{
for (k=j+1;k<=n;k++)
{
if (a[i]+a[j]>=a[k])
{
cate++;
}
}
}
}
fout<<cate;
fin.close();
fout.close();
return 0;
}