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

Pages: 1-

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: HAXUS THE GREAT 2011-11-17 15:18

>>1
>> 2011
progrsmming on eclipse
http://dis.4chan.org/read/prog/1321531728/1-40

Name: Anonymous 2011-11-17 15:20

AbstractLampOilFactorySellerProxy

Name: Anonymous 2011-11-17 15:24

in binary 1,10,100,1000,... represent the decimal numbers 1,2,4,8,...

so consider whether or not the value of 45&b is 0 or not for b = 1,2,4,8,...

this tells you whether or not the i'th bit is 0 or 1 for b = 2^i.

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)));
}

Name: Anonymous 2011-11-17 16:46

>>1,5
ENTERPRISE PROGRAMMERS

Name: Anonymous 2011-11-17 17:54

>>2
>1-40
>only has 5 replies

oh haxus, will you ever learn

Name: Anonymous 2011-11-17 18:57

First, generate all the partitions of a number. Then filter the results for just those which have powers of 2 in them. This should be reasonably fast for numbers less than 50.

Name: Anonymous 2011-11-17 19:43

>>4,5
answer
>>1
translate it to java

Name: Anonymous 2011-11-17 20:04

pubic

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