Răspuns:
#include <iostream>
using namespace std;
int main()
{
int a,b,c, n, i, triplete=0, x;
cin >> n;
cin >> a >> b >> c;
if (a+b>c && a+c>b && b+c>a) ++triplete;
for (i=4; i<=n; ++i)
{
cin >> x;
a=b; b=c; c=x;
if (a+b>c && a+c>b && b+c>a) ++triplete;
}
cout << triplete;
return 0;
}
Explicație: