Advertisement
kamandos

HW1

Jun 29th, 2022
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. class Main{
  2.  
  3. static void Pairs(int arr[], int n)
  4. {
  5.  
  6.     // Nested loop for all possible pairs
  7.     for (int i = 0; i < n; i++) {
  8.         for (int j = 0; j < n; j++) {
  9.             System.out.print("(" +  arr[i]+ ", "
  10.                  + arr[j]+ ")"
  11.                 + ", ");
  12.         }
  13.     }
  14. }
  15.    
  16. public static void main(String[] args)
  17. {
  18.     int arr[] = { 1, 2 };
  19.     int n = arr.length;
  20.  
  21.     Pairs(arr, n);
  22.  
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement