1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| int read4(char *buf);
class Solution { public:
int read(char *buf, int n) { char t[4]; int cnt = read4(t), i = 0, j = 0; if (cnt == 0) return 0; while (i < n && j < cnt) { buf[i++] = t[j++]; } if (i == n) return n; return cnt + read(buf + cnt, n - cnt); } };
|