Issue with 3Sum problem!
Mostrar comentarios más antiguos
Alright so I took some stuff out and now I'm down to this. For some reason though, it's just coming up with random numbers from the array instead of using them to find a 1D array which adds to zero. I think what the issue is, is that it's not using the integers to try and find where T would equal zero.
F = [-5,-4,-3,-2,-1,1,2,3,4,5];
for T = @(a,b,c) (a + b + c);
a = randsample (F,1);
b = randsample (F,1);
c = randsample (F,1);
if T(a,b,c) == 0
disp [a b c]
end
end
Respuesta aceptada
Más respuestas (1)
Nathaniel Ewing
el 29 de Abr. de 2012
0 votos
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!