Method
reverse
(byte[] buf, int begin, int end)
Source from the content-addressed store, hash-verified
| 19 | } |
| 20 | |
| 21 | static void reverse(byte[] buf, int begin, int end) { |
| 22 | while (true) { |
| 23 | byte bb = buf[begin]; |
| 24 | if (bb == '\n') bb = buf[++begin]; |
| 25 | byte be = buf[end]; |
| 26 | if (be == '\n') be = buf[--end]; |
| 27 | if (begin > end) break; |
| 28 | buf[begin++] = map[be]; |
| 29 | buf[end--] = map[bb]; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | public static void main(String[] args) throws IOException { |
| 34 | final byte[] buf = new byte[System.in.available()]; |
Tested by
no test coverage detected