Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. public static void main(String[] args) throws FileNotFoundException, IOException {
  2. Scanner in = new Scanner(System.in);
  3.  
  4.  
  5. List<String> clubes = new ArrayList<String>();
  6. System.out.println("Entre com o nome dos clubes. Deixe em branco para terminar.");
  7. String clube = "";
  8.  
  9.  
  10. do {
  11. clube = in.nextLine().trim();
  12. if (!clube.isEmpty()) {
  13. clubes.add(clube);
  14. }
  15. } while (!clube.isEmpty());
  16.  
  17. if (clubes.size() % 2 == 1) {
  18. clubes.add(0, "");
  19. }
  20.  
  21.  
  22.  
  23. int t = clubes.size();
  24. int m = clubes.size() / 2;
  25.  
  26.  
  27. for (int i = 0; i < t - 1; i++) {
  28.  
  29. System.out.print((i + 1) + "a rodada: ");
  30. for (int j = 0; j < m; j++) {
  31. //Clube está de fora nessa rodada?
  32. if (clubes.get(j).isEmpty())
  33. continue;
  34.  
  35. //Teste para ajustar o mando de campo
  36. if (j % 2 == 1 || i % 2 == 1 && j == 0) {
  37.  
  38. row.createCell(j+1).setCellValue(clubes.get(t - j - 1) + " x " + clubes.get(j) + " ");
  39. System.out.print(clubes.get(t - j - 1) + " x " + clubes.get(j) + " ");
  40.  
  41. }
  42. else{
  43. row.createCell(j+1).setCellValue(clubes.get(j) + " x " + clubes.get(t - j - 1) + " ");
  44. System.out.print(clubes.get(j) + " x " + clubes.get(t - j - 1) + " ");
  45.  
  46. }
  47.  
  48. }
  49. System.out.println();
  50. //Gira os clubes no sentido horário, mantendo o primeiro no lugar
  51. clubes.add(1, clubes.remove(clubes.size()-1));
  52. }
  53. }
  54.  
  55. $t = count($array);
  56. $m = count($array)/2;
  57.  
  58. for ($i = 0; $i < $t - 1; $i++) {
  59. echo $i+1 ."a rodada: <br>";
  60.  
  61. for ($j = 0; $j < $m; $j++) {
  62. //Clube está de fora nessa rodada?
  63. if ($array[$j] == 'Stand by')
  64. continue;
  65.  
  66. //Teste para ajustar o mando de campo
  67. if ($j%2 == 1 || $i%2 == 1 && $j == 0) {
  68.  
  69. echo print_r($array[$t-$j-1], true)." x ". print_r($array[$j],true)."<br>";
  70.  
  71. }
  72. else{
  73. echo print_r($array[$j],true). " x ".print_r($array[$t-$j-1],true)."<br>";
  74. }
  75. }
  76.  
  77.  
  78. array_pop($array);
  79. $novo_array = array();
  80. $novo_array = $array[0];
  81. array_shift($array);
  82. array_unshift($array, $novo_array);
  83.  
  84. echo "J -> $array[$j]";
  85.  
  86. echo "array da rodada $i:<br>";
  87. print_r($array);
  88.  
  89. } //O $array no PHP é a list do Java
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement