Programming Algorithm-combined number code (C)

Source: Internet
Author: User

Programming Algorithm-combined number code (C)
Combination code (C)

 

 

 

The number of combinations of a string, such as abc. The output is a, B, c, ac, AB, bc, and abc, that is, the combination that contains the sequence.

SimilarFull ranking of BITs, Such as 001,010,100,011,101,110,111.

 

Code:

 

/** Main. cpp ** Created on: 2014.7.20 * Author: Spike * // * eclipse cdt, gcc 4.8.1 */# include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
Using namespace std; string BinaryString (string s, int I) {string tmp; int k = 0; while (I! = 0) {if (I & 0x1) tmp. push_back (s [k]); k ++; I >>= 1;} return tmp;} vector
     
      
Combination (string s) {vector
      
        Vs; if (s. length () = 0) return vs; int num = pow (2.0, s. length (); for (int I = 1; I
       
         Vs = Combination (s); for (size_t I = 0; I
        
         

 

 

 

Output:

 

 

ababcacbcabc


 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.