主要是看懂题。。
用给你提供的read4去实现readN,是这个意思。。
/* The read4 API is defined in the parent class Reader4.
int read4(char[] buf); */
public class Solution extends Reader4 {
/**
* @param buf Destination buffer
* @param n Maximum number of characters to read
* @return The number of characters read
*/
public int read(char[] buf, int n)
{
int res = 0;
while(res < n)
{
char[] temp = new char[4];
int a = read4(temp);
int b = 0;
while(a > 0 && res < n)
{
buf[res++] = temp[b++];
a--;
}
if(b < 4) break;
}
return res;
}
}