$times = array('Time1','Time2','Time3','Time4','Time5','Time6','Time7','Time8','Time9','Time10'); //Array de Times
$qtde_times = count($times); // Quantidade de Times
$num_rodadas = $qtde_times - 1; //numero de rodadas
$times_por_rodada = 2 * (int) ($qtde_times / 2);
$casa = array(); //guarda os jogos de quem joga em casa
$fora = array(); // guarda os jogos de quem joga fora
$jogos = array(); // guarda os jogos no final
$jogos_temp = array(); //array temporário, verifica quem já jogou em cada rodada
for ($i = 0; $i < $qtde_times; $i++) { //For para caminhar entre os times
for ($j = $i; $j < $qtde_times; $j++) { //For para caminha entre os adversários
if ($times[$i] != $times[$j]) { //verifica pra não deixar jogar um time contra ele mesmo
if ($j % 2 == 0) { //if pra ver quem joga em casa ou fora
$casa[] = $times[$i];
$fora[] = $times[$j];
} else {
$casa[] = $times[$j];
$fora[] = $times[$i];
}//fim do if / else de jogar em casa ou fora
}// verifica se é diferente pra poder fazer o confronto
}// fim do for que caminha entre os adversários
}// fim do for que verifica os times
//
//parte que verifica quem já jogou em qual rodada
for ($rodada = 0; $rodada < $num_rodadas; $rodada++) {
for ($t = 0; $t < count($casa); $t++) {
if (($casa[$t] != "") and ((in_array($casa[$t], $jogos_temp)) == false) and (((in_array($fora[$t], $jogos_temp)) == false))) {
$jogos_temp[] = $casa[$t];
$jogos_temp[] = $fora[$t];
$casa[$t] = "";
$fora[$t] = "";
}
}
$jogos["Rodada: " . ($rodada + 1)] = $jogos_temp;
$jogos_temp = array();
}
for ($rod = 0; $rod < $num_rodadas; $rod++) {
echo "Rodada: " . ($rod + 1) . "<br />";
for ($jog = 0; $jog < $times_por_rodada; $jog+=2) {
echo $jogos["Rodada: " . ($rod + 1)][$jog] . " x " . $jogos["Rodada: " . ($rod + 1)][($jog + 1)] . "<br />";
}
echo "<br />";
}
JHRpbWVzID0gYXJyYXkoJ1RpbWUxJywnVGltZTInLCdUaW1lMycsJ1RpbWU0JywnVGltZTUnLCdUaW1lNicsJ1RpbWU3JywnVGltZTgnLCdUaW1lOScsJ1Rpb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wID0gYXJyYXkoKTsKfQogCmZvciAoJHJvZCA9IDA7ICRyb2QgPCAkbnVtX3JvZGFkYXM7ICRyb2QrKykgewogICAgZWNobyAiUm9kYWRhOiAiIC4gKCRyb2QgKyAxKSAuICI8YnIgLz4iOwogICAgZm9yICgkam9nID0gMDsgJGpvZyA8ICR0aW1lc19wb3Jfcm9kYWRhOyAkam9nKz0yKSB7CiAgICAgICAgZWNobyAkam9nb3NbIlJvZGFkYTogIiAuICgkcm9kICsgMSldWyRqb2ddIC4gIiB4ICIgLiAkam9nb3NbIlJvZGFkYTogIiAuICgkcm9kICsgMSldWygkam9nICsgMSldIC4gIjxiciAvPiI7CiAgICB9CiAgICBlY2hvICI8YnIgLz4iOwp9
Main.java:1: error: class, interface, or enum expected
$times = array('Time1','Time2','Time3','Time4','Time5','Time6','Time7','Time8','Time9','Time10'); //Array de Times
^
Main.java:1: error: unclosed character literal
$times = array('Time1','Time2','Time3','Time4','Time5','Time6','Time7','Time8','Time9','Time10'); //Array de Times
^
Main.java:1: error: unclosed character literal
$times = array('Time1','Time2','Time3','Time4','Time5','Time6','Time7','Time8','Time9','Time10'); //Array de Times
^
Main.java:2: error: class, interface, or enum expected
$qtde_times = count($times); // Quantidade de Times
^
Main.java:3: error: class, interface, or enum expected
$num_rodadas = $qtde_times - 1; //numero de rodadas
^
Main.java:4: error: class, interface, or enum expected
$times_por_rodada = 2 * (int) ($qtde_times / 2);
^
Main.java:5: error: class, interface, or enum expected
$casa = array(); //guarda os jogos de quem joga em casa
^
Main.java:6: error: class, interface, or enum expected
$fora = array(); // guarda os jogos de quem joga fora
^
Main.java:7: error: class, interface, or enum expected
$jogos = array(); // guarda os jogos no final
^
Main.java:8: error: class, interface, or enum expected
$jogos_temp = array(); //array tempor?rio, verifica quem j? jogou em cada rodada
^
Main.java:9: error: class, interface, or enum expected
for ($i = 0; $i < $qtde_times; $i++) { //For para caminhar entre os times
^
Main.java:9: error: class, interface, or enum expected
for ($i = 0; $i < $qtde_times; $i++) { //For para caminhar entre os times
^
Main.java:9: error: class, interface, or enum expected
for ($i = 0; $i < $qtde_times; $i++) { //For para caminhar entre os times
^
Main.java:10: error: class, interface, or enum expected
for ($j = $i; $j < $qtde_times; $j++) { //For para caminha entre os advers?rios
^
Main.java:10: error: class, interface, or enum expected
for ($j = $i; $j < $qtde_times; $j++) { //For para caminha entre os advers?rios
^
Main.java:14: error: class, interface, or enum expected
$fora[] = $times[$j];
^
Main.java:15: error: class, interface, or enum expected
} else {
^
Main.java:17: error: class, interface, or enum expected
$fora[] = $times[$i];
^
Main.java:18: error: class, interface, or enum expected
}//fim do if / else de jogar em casa ou fora
^
Main.java:26: error: class, interface, or enum expected
for ($rodada = 0; $rodada < $num_rodadas; $rodada++) {
^
Main.java:26: error: class, interface, or enum expected
for ($rodada = 0; $rodada < $num_rodadas; $rodada++) {
^
Main.java:27: error: class, interface, or enum expected
for ($t = 0; $t < count($casa); $t++) {
^
Main.java:27: error: class, interface, or enum expected
for ($t = 0; $t < count($casa); $t++) {
^
Main.java:30: error: class, interface, or enum expected
$jogos_temp[] = $fora[$t];
^
Main.java:31: error: class, interface, or enum expected
$casa[$t] = "";
^
Main.java:32: error: class, interface, or enum expected
$fora[$t] = "";
^
Main.java:33: error: class, interface, or enum expected
}
^
Main.java:36: error: class, interface, or enum expected
$jogos_temp = array();
^
Main.java:37: error: class, interface, or enum expected
}
^
Main.java:39: error: class, interface, or enum expected
for ($rod = 0; $rod < $num_rodadas; $rod++) {
^
Main.java:39: error: class, interface, or enum expected
for ($rod = 0; $rod < $num_rodadas; $rod++) {
^
Main.java:41: error: class, interface, or enum expected
for ($jog = 0; $jog < $times_por_rodada; $jog+=2) {
^
Main.java:41: error: class, interface, or enum expected
for ($jog = 0; $jog < $times_por_rodada; $jog+=2) {
^
Main.java:41: error: class, interface, or enum expected
for ($jog = 0; $jog < $times_por_rodada; $jog+=2) {
^
Main.java:43: error: class, interface, or enum expected
}
^
Main.java:45: error: class, interface, or enum expected
}
^
36 errors