Numerical Combinations in C

I can't come up with a generic code for a problem like this example

I have 1, 2, and 3 in a vector or 12345.... depending on the input.

There are 6 possible combinations without repeating the same numbers again

123 132 213 231 321 312

Can anyone help?

This is one of the functions I use. I have another for the actual combination

void troca(int *a, int *b)
{
    int x;

    x=*a;
    *a=*b;
    *b=x;
}

Answers


Are you using c++? (You mentioned vector)

Try next_permutation


Need Your Help

Filtering in Firebase Android

android firebase firebase-realtime-database

I am developing an android app using Firebase in which data structure consists of Hotel table consisting of city name along with latitude and longitude as shown in below image.

How to put a character limit on a UITextField

xcode nsstring uitextfield limit character

I would like to put a character limit on a UITextField but don't know how. I want it to have a maximum of 16 characters in it. How do I do this.