Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java Programming

Name: Anonymous 2011-11-17 15:08

Make a program that reads and writes a positive value in the decomposition of sums of powers of 2, in descending order. Consider that the reading is less than 2 ^ 31.

is not allowed to use methods of the Arrays class of java.lang package and Math.

example:

Value? 45
45 = 2 ^ 5 + 2 ^ 3 + 2 ^ 2 + 2 ^ 0

any ideas or tips? rly need this bros

programming on eclipse

Name: Anonymous 2011-11-17 16:18


static String hurr(int durr, int derp) {
 return (durr)? hurr(durr>>1, derp+1) + ((durr&1)? " + 2 ^ " + derp : "") : "";
}

pubic static void main(String argv) {
 System.out.println(hurr(System.libc.atoi(argv[1],0)));
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List