Answers for "triplets in an array"

1

triplet in array

import java.io.*;
import java.util.*;


public class Main
{
  public static void main (String[]args)
  {

     int a[] = { 1,2,3,4,5,6};
     int n = a.length;
     
     
     
     for(int i=0;i<n-1;i++){
        int l = i+1;
        int r = n-1;
        int x = a[i];
         while(l<r){
             System.out.print("("+ x +","+ a[l] +","+ a[r]+") ");
             r--;
         }
     }
  
  }
}
Posted by: Guest on March-07-2021

Code answers related to "triplets in an array"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language