Problem:
I did a similar question before, but this time it still doesn't solve the problem.
String upside down: StringBuffer str=new stringbuffer (s); S=str.reverse (). ToString ()
BitsetTime limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 15548 Accepted Submission (s): 11804
Problem descriptiongive you a number on the base ten,you should output it on base. (0 < n < 1000)
Inputfor Each case there was a postive number n on base ten, end of file.
Outputfor each case, output a number on base.
Sample Input
123
Sample Output
11011
Code:
Import java.util.*;p ublic class main{public static void Main (String args[]) {Scanner cin=new Scanner (system.in); while ( Cin.hasnext ()) {int n=cin.nextint (); String s= ""; while (n!=0) {s=s+ (n%2); N=N/2;} StringBuffer str=new StringBuffer (s); S=str.reverse (). toString (); System.out.println (str);}}}
HDU 2051 Bitset (Java)