Team Flower Trouble One (nyoj275)

Source: Internet
Author: User

Team spend the trouble of a time limit: theMs | Memory Limit:65535KB Difficulty:1
Describe

ACM Team spend C small + often complained: "C language in the format output has 16, 10 or eight output, but there is no binary output, hey, it's a pity!" Who can help me write a program implementation input a decimal number n, output its binary number ah? ”

Don't you want to help her? ^_^

Input
the input has multiple data, the data ends with EOF, and each data ni (0<=ni<=1000010000) is separated by a space;
(Hint: EOF is the end flag for a file; while (scanf ("%d", &n)!=eof) {})
Output
output has multiple lines, each line corresponds to a decimal number of NI binary number;
Note: The output binary removes any extra 0;
Sample input
0 1 2 10
Sample output
01101010
Source
Original
Uploaded by

Never

#include <stdio.h> #include <string.h>int main () {int I,n;int a[1000];while (scanf ("%d", &n)!=eof) {i=0; memset (A,0,sizeof (a)); if (n==0) printf ("0\n"); Else{while (n) {a[i]=n%2;n/=2;i++;} for (i=i-1;i>=0;i--)    printf ("%d", A[i]);p rintf ("\ n");}} return 0;}

Team Flower Trouble One (nyoj275)

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.