WRONG SECTION

WRONG SECTION!
Last edited on
> using bit shift operator and a loop

Using bit shift operator, and a few other bitwise operators, and a loop:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <string>
#include <locale>

int main()
{
    std::locale::global( std::locale("en_US.UTF-8") ) ;

    std::string str = "A" ;

    while( str.size() < 26 )
    {
        unsigned int c = str.back() ;
        unsigned int bit = 1U ;

        while( c & bit )
        {
            c &= ~bit ;
            bit <<= 1U ;
        }

        str += c | bit  ;
    }

    std::cout << str << '\n' ;
}

http://coliru.stacked-crooked.com/a/4dbbfff24028b1c6
Topic archived. No new replies allowed.