pair in array

Solutions on MaxInterview for pair in array by the best coders in the world

showing results for - "pair in array"
Alessio
01 May 2019
1import java.io.*;
2import java.util.*;
3
4
5public class Main
6{
7  public static void main (String[]args)
8  {
9
10     int a[] = { 1,2,3,4,5,6};
11     int n = a.length;
12     
13     
14     int r = n-1;
15     for(int i=0;i<n;i++){
16         int l = i;
17         while(l<r){
18             System.out.print("("+a[l]+","+a[r] + ")   ");
19             r--;
20         }
21         r=n-1;
22     }
23     
24  }
25}