fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. int n = in.nextInt();
  11. int[][] x = new int[n][n];
  12. for(int i = 0; i < n; i++) {
  13. for(int j = 0; j < n; j++) {
  14. x[i][j] = in.nextInt();
  15. }
  16. }
  17. for(int i = 0; i < n; i++) {
  18. for(int j = i; j < n; j++) {
  19. if(x[i][j] == 1) System.out.println((i+1) + " " + (j+1));
  20. }
  21. }
  22. }
  23. }
  24.  
Success #stdin #stdout 0.06s 2184192KB
stdin
5
0 1 0 1 1
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 0
stdout
1 2
1 4
1 5