Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
BlueHost Web Hosting

Bonsai Boy of New York Bonsai Trees and Accessories

Liquid Web iThemes WordPress Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

DreamHost Web Hosting


getResponse autofunnels

Liquid Web Cloud VPS Hosting

11,818 questions

16,089 answers

573 users

How to print all permutations of a string with the same sequence and different cases in C++

1 Answer

0 votes
#include <bits/stdc++.h>
    
using namespace std;

void permutation(string s) { 

    transform(s.begin(), s.end(), s.begin(), ::tolower); 

    int len = s.length(); 
    int total_sets = 1 << len; 

    for (int i = 0; i < total_sets; i++) { 
        string combination = s; 
        for (int j = 0; j < len; j++) { 
            if (((i >> j) & 1)) {
                 combination[j] = toupper(s.at(j));     
            }
        }
        cout << combination << endl; 
    } 
} 

int main() 
{ 
    permutation("abc"); 

    return 0; 
}
 
    
    
    
/*
run:
    
abc
Abc
aBc
ABc
abC
AbC
aBC
ABC
    
*/

 




answered Aug 10 by avibootz
...