bskfred's blog

By bskfred, history, 4 weeks ago, In English,

Hello!

What's wrong with that code?

https://github.com/fredryco/Grafos/blob/master/Trabalhos/src/Museum.java

https://github.com/fredryco/Grafos/blob/master/Trabalhos/src/Questao4.java

I know the class name must by Main, i switch when submit this, but i got this message "Runtime error on test 1"

Someone can help me

 
 
 
 

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by bskfred (previous revision, new revision, compare).

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

It's actually full of bugs. You always reinitalize your sc variable. You should call new Scanner(System.in) only once, at the beginning of the program. Also sc.nextLine() reads an empty line for the first time, because after reading 3 ints from the first line, the scanner didn't go past the first '\n', so you have to call an sc.nextLine() before the for loop, after reading the 3 ints. In the dfs function there is overindexing, because you don't check for both variable's limits.

If you go into your submission, you can see details of your runtime error, the judge gives even the line of the error, and the type of it also, by googling it, you can find out the error yourself.