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)