Count the number of rhombi possible inside a rectangle of given size | C ++ implementation of the approach ; Function to return the count of rhombi possible ; All possible diagonal lengths ; Update rhombi possible with the current diagonal lengths ; Return the total count of rhombi possible ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; long long countRhombi ( int h , int w ) { long long ct = 0 ; for ( int i = 2 ; i <= h ; i += 2 ) for ( int j = 2 ; j <= w ; j += 2 ) ct += ( h - i + 1 ) * ( w - j + 1 ) ; return ct ; } int main ( ) { int h = 2 , w = 2 ; cout << countRhombi ( h , w ) ; return 0 ; }