0

How to make different combination of lines of a matrix. Or how can i learn make combinattions in c++

8th Nov 2016, 1:39 PM
Eren Cayıklı
Eren Cayıklı - avatar
4 Réponses
+ 2
I don't know about Johnson's method, but here's the method for permuting a string. You can do the same for an integer array. #include <iostream> using namespace std; void perm(string s,string t) { if(s.length() == 0){ cout<<t<<endl; return; } for(int i=0;i<s.length();i++){ string s2 = s; string t2 = t; s2.erase(i,1); t2 += s[i]; perm(s2,t2); } } int main() { string s = "xyz"; string t; perm(s,t); } as far as 2d array is concerned, i guess you first need to find all the permutation of every row. and then find permutation of coloumns. If some other idea strikes you regarding permutation of 2d array, do post it here!!
8th Nov 2016, 7:51 PM
kamal joshi
kamal joshi - avatar
+ 1
did you mean generating permutations for some array or string??
8th Nov 2016, 7:22 PM
kamal joshi
kamal joshi - avatar
0
yes actually i want to try to improve the johnson's method about endustrial engineering. it will do all the possible combinations of machining and then find the cheapest and fastest way. i need to find all the combinations of an 2 dimention array's lines.
8th Nov 2016, 7:32 PM
Eren Cayıklı
Eren Cayıklı - avatar
0
well thank you very much. i think it will be very usefull. if a manage what i wanted i will post it here.
8th Nov 2016, 8:00 PM
Eren Cayıklı
Eren Cayıklı - avatar