Simple binary conversion, just take a look at the data range.
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> #define MAXN + int A[MAXN]; int main () { int n,i,j; while (scanf ("%d", &n)!=eof) { if (n==0) { printf ("0\n"); Continue; } i=0; while (n) { a[i++]=n%2; n/=2; } for (j=i-1;j>=0;j--) { printf ("%d", a[j]); } printf ("\ n"); } return 0; }
Nyoj 275 Team Flower Trouble One "binary conversion"