问道FB的题# JobHunting - 待字闺中
z*m
1 楼
Given 2 functions String recv() and String ReadLine()
recv() generates some string (Example:"123n45n6789").
ReadLine() should read the string being returned by recv() and print all
characters until the first n.
After that it should read the recv() string again and print the next
characters until the 2nd n.
Example: recv(): "123n45n6789"
ReadLine(): "123" //first call of ReadLine
ReadLine(): "45" // second call of ReadLine
However, the next sequence now doesn't have a n. So, once the end of the
string is hit, the ReadLine() function must call recv() again, and append
all characters until it reads a n.
Continuing the above example: ReadLine():6789abcde //Third call of ReadLine
recv():"abc"// still no n...so you must call recv() again
recv():"den"
recv() generates some string (Example:"123n45n6789").
ReadLine() should read the string being returned by recv() and print all
characters until the first n.
After that it should read the recv() string again and print the next
characters until the 2nd n.
Example: recv(): "123n45n6789"
ReadLine(): "123" //first call of ReadLine
ReadLine(): "45" // second call of ReadLine
However, the next sequence now doesn't have a n. So, once the end of the
string is hit, the ReadLine() function must call recv() again, and append
all characters until it reads a n.
Continuing the above example: ReadLine():6789abcde //Third call of ReadLine
recv():"abc"// still no n...so you must call recv() again
recv():"den"