nearly similar rectangles hackerrank solution code example
Example 1: Rectangle area hackerrank solution in c++
#include <iostream>
using namespace std;
class Rectangle{
protected:
int width;
int height;
public:
virtual void display() const{
cout<< width <<' ' << height << endl;
}
};
class RectangleArea : public Rectangle {
public:
void display() const override {
cout << (width * height) << endl;
}
void read_input(){
cin >> width >> height;
}
};
int main()
{
RectangleArea r_area;
r_area.read_input();
r_area.Rectangle::display();
r_area.display();
return 0;
}
Example 2: nearly similar rectangles hackerrank solution
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll combinations(ll n)
{
ll count=1;
if(n<2)
return 0;
else
{
for(ll i=1;i<=2;i++)
{
count=count*n--;
count=count/i;
}
}
return count;
}