+ 1

# Possible combinations

Write a program to accept three digits (i.e., 0-9)and print all possible combinations from these digits. for example, if the three digits are 1, 2 and 3 then all possible combinations are 123, 132, 23 1, 213, 312 and 321.

5th Sep 2018, 2:50 AM
Heena Parween + 2
Thank you
5th Sep 2018, 12:17 PM
Heena Parween + 1
include<iostream> int main() { int a; cout<<"Enter three digits :"<<endl; cin>>a>>a>>a; for (int i=0;i<3;i++) { for(int j=0;j<3;j++) { for (int k=0;k<3;k++) { if (i!=j&&i!=k&&j!=k) cout<<endl<<endl<<a[i]<<a[j]<<a[k]; } } } return 0 ; } This is the code but I am not getting the correct answer by executing this code..
5th Sep 2018, 4:33 AM
Heena Parween + 1
Then what will be the code..???
5th Sep 2018, 6:57 AM
Heena Parween + 1
Heena Parween Here's my attempt. The permute function swap the value of the array's elements then print the modified array. You can modify the code to get user input and use other concept for further optimization. https://code.sololearn.com/cde3K9Hyl0d0/?ref=app
5th Sep 2018, 12:14 PM
Hoàng Nguyễn Văn 0
More like permutation than combination. Is this a question or a challenge you're proposing?
5th Sep 2018, 3:02 AM
Hoàng Nguyễn Văn 0
cout << a[i] << a[j] << a[k] will always print the same result unless you: 1. Modify how the result is printed to the console. 2. Modify the array elements.
5th Sep 2018, 6:54 AM
Hoàng Nguyễn Văn 