Count pairs of similar rectangles possible from a given array | C ++ Program for the above approach ; Function to calculate the count of similar rectangles ; Driver Code ; Input
#include <iostream> NEW_LINE using namespace std ; int getCount ( int rows , int columns , int A [ ] [ 2 ] ) { int res = 0 ; for ( int i = 0 ; i < rows ; i ++ ) { for ( int j = i + 1 ; j < rows ; j ++ ) { if ( A [ i ] [ 0 ] * 1LL * A [ j ] [ 1 ] == A [ i ] [ 1 ] * 1LL * A [ j ] [ 0 ] ) { res ++ ; } } } return res ; } int main ( ) { int A [ ] [ 2 ] = { { 4 , 8 } , { 10 , 20 } , { 15 , 30 } , { 3 , 6 } } ; int columns = 2 ; int rows = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << getCount ( rows , columns , A ) ; return 0 ; }