Skip to content

Instantly share code, notes, and snippets.

@lnrsoft
Last active January 21, 2019 10:10
Show Gist options
  • Save lnrsoft/291156cfa9852bbaf96c9f8745d9fc1a to your computer and use it in GitHub Desktop.
Save lnrsoft/291156cfa9852bbaf96c9f8745d9fc1a to your computer and use it in GitHub Desktop.
Box It HRANK problem in c++
// This source code written by Roland Ihasz
#include<bits/stdc++.h>
// #include <iostream>
using namespace std;
class Box {
private:
int l, b, h;
public:
Box()
{
l = 0;
b = 0;
h = 0;
}
Box(int length, int breadth, int height)
{
l = length;
b = breadth;
h = height;
}
Box(const Box &B)
{
l = B.l;
b = B.b;
h = B.h;
}
int getLenght()
{
return l;
}
int getBreadth()
{
return b;
}
int getHeight()
{
return h;
}
long long CalculateVolume()
{
return (long long)l*b*h;
}
friend bool operator<(Box &A, Box &B)
{
return (A.l < B.l) || ((A.b < B.b) && (A.l == B.l)) ||
((A.h < B.h) && (A.l == B.l) && (A.b == B.b));
}
friend ostream &operator<<(ostream &output, const Box &B)
{
output << B.l << " " << B.b << " " << B.h;
return output;
}
};
void check2()
{
int n;
cin>>n;
Box temp;
for(int i=0;i<n;i++)
{
int type;
cin>>type;
if(type ==1)
{
cout<<temp<<endl;
}
if(type == 2)
{
int l,b,h;
cin>>l>>b>>h;
Box NewBox(l,b,h);
temp=NewBox;
cout<<temp<<endl;
}
if(type==3)
{
int l,b,h;
cin>>l>>b>>h;
Box NewBox(l,b,h);
if(NewBox<temp)
{
cout<<"Lesser\n";
}
else
{
cout<<"Greater\n";
}
}
if(type==4)
{
cout<<temp.CalculateVolume()<<endl;
}
if(type==5)
{
Box NewBox(temp);
cout<<NewBox<<endl;
}
}
}
int main()
{
check2();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment