#include<bits/stdc++.h>
using namespace std;
void findTriplets(int arr[], int n)
{
bool found = true;
for (int i=0; i<n-2; i++)
{
for (int j=i+1; j<n-1; j++)
{
for (int k=j+1; k<n; k++)
{
if (arr[i]+arr[j]+arr[k] == 0)
{
cout << arr[i] << " "
<< arr[j] << " "
<< arr[k] <<endl;
found = true;
}
}
}
}
if (found == false)
cout << " not exist "<<endl;
}
int main()
{
int arr[10];
int i;
for(i=0;i<5;i++)
cin>>arr[i];
findTriplets(arr, 5);
return 0;
}
using namespace std;
void findTriplets(int arr[], int n)
{
bool found = true;
for (int i=0; i<n-2; i++)
{
for (int j=i+1; j<n-1; j++)
{
for (int k=j+1; k<n; k++)
{
if (arr[i]+arr[j]+arr[k] == 0)
{
cout << arr[i] << " "
<< arr[j] << " "
<< arr[k] <<endl;
found = true;
}
}
}
}
if (found == false)
cout << " not exist "<<endl;
}
int main()
{
int arr[10];
int i;
for(i=0;i<5;i++)
cin>>arr[i];
findTriplets(arr, 5);
return 0;
}
change language to cpp
ReplyDeletewhat is the question yaar
ReplyDelete