Issue with 3Sum problem!
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (1)
Nathaniel Ewing
le 29 Avr 2012
0 votes
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!