Skip to content

Commit 8d866ca

Browse files
committed
Added 4 CPP solutions to HR
1 parent c1f9f34 commit 8d866ca

4 files changed

Lines changed: 147 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <cmath>
2+
#include <cstdio>
3+
#include <vector>
4+
#include <iostream>
5+
#include <algorithm>
6+
using namespace std;
7+
8+
9+
class Triangle{
10+
public:
11+
void triangle(){
12+
cout<<"I am a triangle\n";
13+
}
14+
};
15+
class Isosceles : public Triangle{
16+
public:
17+
void isosceles(){
18+
cout<<"I am an isosceles triangle\n";
19+
}
20+
//Write your code here.
21+
void description() {
22+
cout << "In an isosceles triangle two sides are equal\n";
23+
}
24+
};
25+
int main(){
26+
Isosceles isc;
27+
isc.isosceles();
28+
isc.description();
29+
isc.triangle();
30+
return 0;
31+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <cmath>
2+
#include <cstdio>
3+
#include <vector>
4+
#include <iostream>
5+
#include <algorithm>
6+
using namespace std;
7+
8+
class Triangle{
9+
public:
10+
void triangle(){
11+
cout<<"I am a triangle\n";
12+
}
13+
};
14+
15+
class Isosceles : public Triangle{
16+
public:
17+
void isosceles(){
18+
cout<<"I am an isosceles triangle\n";
19+
}
20+
};
21+
22+
class Equilateral : public Isosceles {
23+
public:
24+
void equilateral() {
25+
cout << "I am an equilateral triangle\n";
26+
}
27+
};
28+
29+
//Write your code here.
30+
int main(){
31+
32+
Equilateral eqr;
33+
eqr.equilateral();
34+
eqr.isosceles();
35+
eqr.triangle();
36+
return 0;
37+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
include <iostream>
2+
3+
using namespace std;
4+
5+
6+
/*
7+
* Create classes Rectangle and RectangleArea
8+
*/
9+
class Rectangle {
10+
public:
11+
int height;
12+
int width;
13+
14+
void display() {
15+
cout << height << " " << width << endl;
16+
}
17+
};
18+
19+
class RectangleArea : public Rectangle {
20+
public:
21+
22+
void read_input() {
23+
cin >> this->height >> this->width;
24+
}
25+
26+
void display() {
27+
cout << this->height*this->width << endl;
28+
}
29+
};
30+
31+
int main()
32+
{
33+
/*
34+
* Declare a RectangleArea object
35+
*/
36+
RectangleArea r_area;
37+
38+
/*
39+
* Read the width and height
40+
*/
41+
r_area.read_input();
42+
43+
/*
44+
* Print the width and height
45+
*/
46+
r_area.Rectangle::display();
47+
48+
/*
49+
* Print the area
50+
*/
51+
r_area.display();
52+
53+
return 0;
54+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <iostream>
2+
#include <iomanip>
3+
using namespace std;
4+
5+
int main() {
6+
int T; cin >> T;
7+
cout << setiosflags(ios::uppercase);
8+
cout << setw(0xf) << internal;
9+
while(T--) {
10+
double A; cin >> A;
11+
double B; cin >> B;
12+
double C; cin >> C;
13+
cout << hex << left << showbase << nouppercase;
14+
cout << (long long) A << endl;
15+
16+
cout << dec << right << setw(15) << setfill('_') << showpos << fixed << setprecision(2);
17+
cout << B << endl;
18+
19+
cout << scientific << uppercase << noshowpos << setprecision(9);
20+
cout << C << endl;
21+
22+
}
23+
24+
return 0;
25+
}

0 commit comments

Comments
 (0)