Sorting even numbers from a file

  • 7
  • Locked
  • Bonus task
If one ordered isomorph isn't sure if another ordered isomorph is sober, he asks him to pass a simple test: read a file name from the console, read a set of numbers from the file, sort only the even numbers in ascending order, and then display them on the screen. Can you pass?
You can't complete this task, because you're not signed in.
  • Popular
  • New
  • Old
You must be signed in to leave a comment
OlehLevel 32 , Kyiv
28 February, 12:36
Lost bunch of time before my first try to verify task on fixing bug. But to the surprise verifier doesn't even check this scenario. The problem was that last line of file didn't read. My algorithm was next: 1. Read file by bytes; 2. Save byte to the buffer if it doesn't equal 10 (ASCII's end of line) ; 3. If byte equals 10 then convert buffer to the string (and then to the int) 4. Add converted buffer to the arraylist. 5. erase buffer So as you can see, if there is no empty line in the end then last number doesn't add to the arraylist either. How can i check end of file, if i am using P.S. Should i create this question in the help section even i already completed the task?