Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class Interactive {
  5.  
  6. public static void main(String[] args) {
  7.  
  8. Scanner in = new Scanner(System.in);
  9. int n = in.nextInt();
  10. int i1, i2, mosse = 2*n;
  11. int numMatch = 0;
  12.  
  13. for (int i = 0; i < mosse; i++) {
  14. if(numMatch==n) {
  15. System.out.printf("-1");
  16. System.out.flush();
  17. return;
  18. }
  19. for (int j = i+1; j < mosse; j++) {
  20. System.out.printf("%d %d", i+1, j+1);
  21. System.out.flush();
  22. String lettura = in.next();
  23. if(lettura.equalsIgnoreCase("MATCH")) {
  24. numMatch++;
  25. break;
  26. } else if(lettura.equalsIgnoreCase("-1")) return;
  27. }
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement