1. don't get the question
2. easy way: print("a number in binary form")
normal way: assume 32bit integers as input, define an array of 32 integers (1, 2, 4, 8, ... 2^31). Run a loop using the 32 integers to bit and the input one by one and print the results.
3. easy way: cat input1 input2 | sort -n -m
c way:
/* END is a big big number that read() returns when it reaches the end of input file */
/* let's also assume that output() won't do anything when a/b are not assigned yet */
while (a != END || b != END) {
if (a
ouput(a); a = read(input1);
} else if (a > b) {
output(b); b = read(input2);
} else {
output(a); output(b); a = read(input1); b = read(input2);
}
}
回複:有朋友的公司招程序員, 要特別強的。 附三道編程題目
所有跟帖:
• for 2, there's a much simpler way -Jamesxu- ♂ (14 bytes) () 08/14/2009 postreply 08:04:07