Analysis of Algorithms | Big | C ++ program for the above approach ; Function to print all possible pairs ; Driver Code ; Given array ; Store the size of the array ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; int print ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i != j ) cout << a [ i ] << " ▁ " << a [ j ] << " STRNEWLINE " ; } } } int main ( ) { int a [ ] = { 1 , 2 , 3 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; print ( a , n ) ; return 0 ; }