http://chortle.ccsu.edu/java5/Notes/chap23/ch23_6. html
The hasNextInt() method returns true if the next set of characters in the input stream can be read in as an int. If they can't be read as an int, or if the end of the file has been reached, then it returns false
Takze to co pises neni pravda. ked to pride na znak ktory neni cislo tak to skonci (lebo hasNextInt vrati FALSE) a teda nedava to ziadne dalsie 0 do pola cisel.
Ked chces aby to preskakovalo znaky tak musis cyklus while urobit zlozitejsi, napr. inspiracia tu
http://www.java2s.com/Code/JavaAPI/java.util/Scann erhasNextInt.htm
Pouzivaj nejaku java referenciu alebo google, ked si nacpes do programu nejaku funkciu tak je nutne si precitat k nej referenciu aby si presne vedel co ti ta funkcia (a teda aj program) bude robit pri roznych (trebars aj chybnych) vstupoch. Nielen lepit to jak cierne skrinky.
P.S. a tvoj program ma IMHO dost vazny problem ak bude mat vstup viac ako 20 riadkov (v C by to bola zavazna bezpecnostna diera)