Generating a combination of strings

I am looking for opitmal method of generating pair of numbers from string number.
For example string 12345
Should produce: 11 12 13 14 15 22 23 24 25 33 34 35 44 45 55
String 121256708
Should produce: 11 12 15 16 17 10 18 22 21 25 26 27 20 28 55 56 57 50 58 66 67 60 68 77 70 78 00 08 88

I've perused the STL algorithms but I'm coming up short on the right combination - if you will.  

Thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hey, try this:

#include <iostream>
#include <string>
#include <deque>
using namespace std;

int main()
        string model;
        cout << "enter string: ";                                                      
         cin >> model;
        deque<string> pairs;                                                            
        string a;
        for (int i=0; i< model.size(); i++)
                for (int j=i; j< model.size(); j++)
                        a = "";

        for (int i=0; i< pairs.size(); i++)
                cout << pairs[i] << " ";                                                
        cout << endl;
        return 1;
forums_mpAuthor Commented:

Your approach doesnt remove duplicates, nonetheless, I had something similar.  I thought perhaps there was a more elegant approach in the form of STL algorithms.  
well, if you want to remove duplicates, an easy way to do it would be to use a <set> instead of a <deque> ... A set is a collection of unique variables, so if you try to insert something that already exists, it won't get inserted twice...

the only difference in the code would be that you would need an iterator to go through the set

set<string> pairs;

... code to load up the set ...

for ( set<string>::iterator t = pairs.begin(), t!= pairs.end(); t++)
      cout << *t << " ";
     cout << endl;

Now, if you consider "21" and "12" a duplicate pair, and you want to watch out for that as well, what you could do is sort the string before you insert it into the set... this can be accomplished like this

#include <algorithm>

sort ( a );

hope this helps,


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.