-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrectangle.cpp
More file actions
52 lines (49 loc) · 1.04 KB
/
rectangle.cpp
File metadata and controls
52 lines (49 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<bits/stdc++.h>
using namespace std;
struct Rectangle {
// your code goes here
// Cac bien thanh vien
// your code goes here
// Hai ham khoi tao
int height;
int length;
Rectangle(){};
Rectangle(int a,int b){
height=a;
length=b;
}
int getPerimeter() {
// your code goes here
return (height+length)*2;
}
void print() {
// your code goes here
for(int i=1;i<=height;i++){
for(int j=1;j<=length;j++){
if(i==1||j==1||i==height||j==length){
cout<<"*";
}
else
cout<<" ";
}
cout<<endl;
}
}
};
int compare(Rectangle a, Rectangle b) {
// your code goes here
int m=a.getPerimeter();
int n=b.getPerimeter();
if(m<n){
return -1;
}
else if(m==n)
return 0;
else
return 1;
}
int main(){
Rectangle a(2, 5), b(3, 4);
cout << a.getPerimeter() << " " << b.getPerimeter() << endl;
cout << compare(a, b);
}