Answers for "nearly similar rectangles hackerrank solution"

C++
0

Rectangle area hackerrank solution in c++

#include <iostream>

using namespace std;
/*
 * Create classes Rectangle and RectangleArea
 */
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()
{
    /*
     * Declare a RectangleArea object
     */
    RectangleArea r_area;
    
    /*
     * Read the width and height
     */
    r_area.read_input();
    
    /*
     * Print the width and height
     */
    r_area.Rectangle::display();
    
    /*
     * Print the area
     */
    r_area.display();
    
    return 0;
}
Posted by: Guest on June-09-2020
0

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;
}
Posted by: Guest on April-02-2021

Code answers related to "nearly similar rectangles hackerrank solution"

Browse Popular Code Answers by Language