head=1; tail=1; que[head]=1; while(head<=tail){ for(i=2;i<=n;i++){ if(map[que[head]][i]==1 && dist[i]==0){ que[++tail]=i; dist[i]=dist[que[head]]+1; } } head++; }
时间: 2024-10-01 12:42:55
head=1; tail=1; que[head]=1; while(head<=tail){ for(i=2;i<=n;i++){ if(map[que[head]][i]==1 && dist[i]==0){ que[++tail]=i; dist[i]=dist[que[head]]+1; } } head++; }