Блог пользователя alamin_2014

Автор alamin_2014, история, 10 лет назад, По-английски

simple dfs code.... why is it not working? please help input : 6 1 1 6 1 2 2 3 2 5 3 4 4 5 code : http://pastebin.com/EazYw5af my code run properly when I remove printf which is out of for loop in dfs function. If I write printf function... it does not work... strange..

  • Проголосовать: нравится
  • -7
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Because It's underfined behaviour. printf("%d %d\n",x,visited[G[x][k]]); At this line, k = G[x].size() because of end of loop.