http://ide.codingblocks.com/#/s/20819
output comes 0
Here’s the corrected code, input part was creating problem.
#include
using namespace std;
bool isTriplet(int arr[], int n)
{
int i,j,k;
for(i=0; i<n; ++i)
{
for(j=i+1; j<n; ++j)
{
for(k=j+1; k<n; ++k)
{
int x = arr[i]*arr[i], y = arr[j]*arr[j], z = arr[k]*arr[k];
if(x==y+z || y == x+z || z == x+y)
{
return true;
}
}
}
}
return false;
}
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
cout<< isTriplet(a,n);
}