cleaned up code and solved input problem for stackoverflow user
fixed compilation problems in the selection sort