Skip to content

Commit c705812

Browse files
authored
Create find_triplet.cpp
1 parent 552f372 commit c705812

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

CPP/array-2d/find_triplet.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
#include<iostream>
3+
using namespace std;
4+
void exp(int arr[],int n,int target){
5+
for(int i=0;i<n;i++){
6+
for(int j=0;j<n;j++){
7+
for(int k=0;k<n;k++){
8+
if(arr[i]+arr[j]+arr[k]==target){
9+
if(arr[i]<arr[j]&&arr[j]<arr[k]){
10+
cout<<"("<<arr[i]<<","<<arr[j]<<","<<arr[k]<<")"<<endl;
11+
}
12+
}
13+
}
14+
}
15+
}
16+
}
17+
int main(){
18+
int arr[]={2,7,4,0,9,5,1,3};
19+
int n=sizeof(arr)/sizeof(arr[0]);
20+
int target=6;
21+
exp(arr,n,target);
22+
return 0;
23+
}
24+
Footer
25+
© 2022 GitHub, Inc.
26+
Footer navigation
27+
Te

0 commit comments

Comments
 (0)