Crazy Binary Conversion II

Source: Internet
Author: User

Crazy Binary Conversion II

Time limit:1000 MS

Memory limit:32768 K

Total submit:309(196 users)

Total accepted:219(193 users)

Rating:

Special Judge: No

Description

The binary conversion is a crazy question, you need to convert an integer into a 32-bit binary form.

Input

There are several sets of test data, for each group of data input a positive integer number,number no more than 32-bit signed integer maximum value, input to the end of the file.

Output

Outputs a corresponding 32-bit binary string for each set of data and wraps it.

Sample Input

1

2

Sample Output

00000000000000000000000000000001

00000000000000000000000000000010

Solve this problem with a new stack and queue knowledge.

#include <iostream> #include <stack>using namespace Std;int main () {int N;while (cin>>n) {Stack<int >ls;while (n!=0) {Ls.push (n%2); n/=2;} for (int i=0;i<32-ls.size (); i++) Cout<<0;while (!ls.empty ()) {cout<<ls.top (); Ls.pop ();} Cout<<endl;} return 0;}


Crazy Binary Conversion II

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.