Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws FileNotFoundException, IOException {
- Scanner in = new Scanner(System.in);
- List<String> clubes = new ArrayList<String>();
- System.out.println("Entre com o nome dos clubes. Deixe em branco para terminar.");
- String clube = "";
- do {
- clube = in.nextLine().trim();
- if (!clube.isEmpty()) {
- clubes.add(clube);
- }
- } while (!clube.isEmpty());
- if (clubes.size() % 2 == 1) {
- clubes.add(0, "");
- }
- int t = clubes.size();
- int m = clubes.size() / 2;
- for (int i = 0; i < t - 1; i++) {
- System.out.print((i + 1) + "a rodada: ");
- for (int j = 0; j < m; j++) {
- //Clube está de fora nessa rodada?
- if (clubes.get(j).isEmpty())
- continue;
- //Teste para ajustar o mando de campo
- if (j % 2 == 1 || i % 2 == 1 && j == 0) {
- row.createCell(j+1).setCellValue(clubes.get(t - j - 1) + " x " + clubes.get(j) + " ");
- System.out.print(clubes.get(t - j - 1) + " x " + clubes.get(j) + " ");
- }
- else{
- row.createCell(j+1).setCellValue(clubes.get(j) + " x " + clubes.get(t - j - 1) + " ");
- System.out.print(clubes.get(j) + " x " + clubes.get(t - j - 1) + " ");
- }
- }
- System.out.println();
- //Gira os clubes no sentido horário, mantendo o primeiro no lugar
- clubes.add(1, clubes.remove(clubes.size()-1));
- }
- }
- $t = count($array);
- $m = count($array)/2;
- for ($i = 0; $i < $t - 1; $i++) {
- echo $i+1 ."a rodada: <br>";
- for ($j = 0; $j < $m; $j++) {
- //Clube está de fora nessa rodada?
- if ($array[$j] == 'Stand by')
- continue;
- //Teste para ajustar o mando de campo
- if ($j%2 == 1 || $i%2 == 1 && $j == 0) {
- echo print_r($array[$t-$j-1], true)." x ". print_r($array[$j],true)."<br>";
- }
- else{
- echo print_r($array[$j],true). " x ".print_r($array[$t-$j-1],true)."<br>";
- }
- }
- array_pop($array);
- $novo_array = array();
- $novo_array = $array[0];
- array_shift($array);
- array_unshift($array, $novo_array);
- echo "J -> $array[$j]";
- echo "array da rodada $i:<br>";
- print_r($array);
- } //O $array no PHP é a list do Java
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement