Decimal is converted to a binary sequence, and the number of outputs is 1, and the sequence of odd and even sequences

Source: Internet
Author: User

★ Decimal conversion to binary sequence, and output 1 number, and sequence of odd-even sequence #include<stdio.h>int main () {int m,i,x,y;char a[32];// int is 4 bytes long, accounting for 32 bit bits int count=0;printf ("Please enter a number: \ n"), scanf ("%d",  &m);for  (i = 0;  i < 32; i++) {if  (m%2 == 1)           //the number of 1 in the statistical sequence {count++;} x = m % 2;            // Decimal conversion to binary y = m / 2;m = y;a[i] = x;} printf ("Binary sequence of this number is: \ n");for  (i = 31; i >= 0; i--) {printf ("%d",  a[i]) ;} printf ("\ n");p rintf ("The number of 1 in this binary sequence is:%d",  count);p rintf ("\ n");p rintf ("Odd sequence of this binary sequence is: \ n");for  (i &NBSP;=&NBSP;30;&NBSP;I&NBSP;&GT;=&NBSP;0;&NBSP;I&NBSP;-=&NBSP;2) {printf ("%d",  a[i]);} printf ("\ n");p rintf ("The even sequence of the binary sequence is: \ n");for  (i = 31; i >= 0; i -= &NBSP;2) {printf ("%d",  a[i]);} printf ("\ n"); RETURN&Nbsp;0;} 

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/E5/wKiom1YJMrCyF8_hAAEYOBp4FVE360.jpg "title=" Run Test " alt= "Wkiom1yjmrcyf8_haaeyobp4fve360.jpg"/>

This article is from the "Warm Smile" blog, please be sure to keep this source http://10738469.blog.51cto.com/10728469/1698922

Decimal is converted to a binary sequence, and the number of outputs is 1, and the sequence of odd and even sequences

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.