Subscribe<?php
header('Content-Type: text/plain');
function showCombinations($string, $traits, $i)
{
if ($i >= count($traits))
echo trim($string) . "\n";
else
{
foreach ($traits[$i] as $trait)
showCombinations("$string $trait", $traits, $i + 1);
}
}
$traits = array
(
array('Happy', 'Sad', 'Angry', 'Hopeful'),
array('Outgoing', 'Introverted'),
array('Tall', 'Short', 'Medium'),
array('Handsome', 'Plain', 'Ugly')
);
showCombinations(', $traits, 0);
?>showCombinations at the end should be two single quotes.
void printCharacters(char[][][] chars){
for (int i = 0; i < chars.length; i++){br>
for (int j = 0; j < chars[i].length; j++){br>
for (int k = 0; k < chars[i][j].length; k++){br>
System.out.println(chars[i][j][k]);
}
}
}
}>>>chars once. It doesn't print out all combinations of characters.You are not logged in, either login or create an account to post comments
((a, b), (c), (), ((d), e, f, ((g))))
posted by cmiller at 2:11 PM on June 11, 2007