Cod sursa(job #2326185)

Utilizator raulsomesanRaul Somesan raulsomesan Data 23 ianuarie 2019 13:14:28
Problema Numarare triunghiuri Scor 0
Compilator cpp-64 Status done
Runda simulare_preoli Marime 0.62 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream fin("nrtri.in");
ofstream fout("nrtri.out");

int v[30005];

int main()
{
    int n;
    fin >> n;
    for(int i = 1 ; i <= n ; ++i)
        fin >> v[i];
    int contor= 0;
    for(int i = 1 ; i <= n ; ++i)
        for(int j = i + 1 ; j <= n ; ++j)
            for(int k = j + 1 ; k <= n ; ++k)
                if(v[i] <= v[j] + v[k] && v[j] <= v[i] + v[k] && v[k] <= v[i] + v[j])
                {
                    ++contor;
                    fout << i << " " << j << " " << k << '\n';
                }
    fout << contor;
}