Write three lines of code in decimal to binary

Source: Internet
Author: User
Tags decimal to binary

Write three lines of code in decimal to binary

Students c ++ retake the exam and asked me to help write the code in decimal to binary. In order to make this students remember it, I wanted to write it simpler. I didn't expect it to be so simple, it feels good. Directly run the Code:

Void DtoB (int d) {if (d/2) DtoB (d/2); cout <

 

  
Considering that some people are very lazy and like to copy the code that can be used, the following is a complete code with the main function:

# Include

   
    
Using namespace std; void DtoB (int d) {if (d/2) DtoB (d/2); cout <

    
     
> N; DtoB (n); cout <

     

      

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.