Count cubes of size K inscribed in a cube of size N | C ++ implementation of the above approach ; Function to find the number of the cubes of the size K ; Stores the number of cubes ; Stores the number of cubes of size k ; Driver Code ; Size of the bigger cube ; Size of the smaller cube
#include <bits/stdc++.h> NEW_LINE using namespace std ; int No_of_cubes ( int N , int K ) { int No = 0 ; No = ( N - K + 1 ) ; No = pow ( No , 3 ) ; return No ; } int main ( ) { int N = 5 ; int K = 2 ; cout << No_of_cubes ( N , K ) ; return 0 ; }