Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
triplets from vector
//Title of this code #include <iostream> #include <vector> #include <tuple> using namespace std; vector<tuple<int,int,int>> getTriplets(vector<int>& t) { vector<tuple<int,int,int>> ret; for (int i = 0; i < t.size(); ++i) for (int j = i + 1; j < t.size(); ++j) for (int k = j + 1; k < t.size(); ++k) if (t[i] < t[j] && t[j] < t[k]) { tuple<int, int, int> triplet(i,j,k); ret.push_back(triplet); } return ret; } void print(vector<int>& t, vector<tuple<int,int,int>>& r) { for (int i = 0; i < r.size(); ++i) { cout << t[get<0>(r[i])] << " " << t[get<1>(r[i])] << " " << t[get<2>(r[i])] << " ---> "; cout << get<0>(r[i]) << " " << get<1>(r[i]) << " " << get<2>(r[i]) << endl; } } int main() { vector<int> t; t.push_back(10); t.push_back(2); t.push_back(6); t.push_back(16); t.push_back(30); t.push_back(13); t.push_back(2); t.push_back(67); vector<tuple<int,int,int>> r = getTriplets(t); print(t, r); }
run
|
edit
|
history
|
help
0
Smalllest subarray wiith sum greater than x
VecHotel2
LRUCache
Korelacja Pearsona lol
Compare boost optional with the actual value
Fungsi dan for
Wipro Problem 2: determine count
10 wizards-DFS_vector
Bad code
Anziktet