Đề bài
A rectangle has two sides of length width and two sides of length height. Its perimeter is the total length of all four sides.
Implement rectangle_perimeter(width, height).
Input
width: The width of the rectangle. height: The height of the rectangle.
Output
Return the perimeter as an integer.
Ràng buộc
1 ≤ width, height ≤ 1,000,000
Ví dụ
Đầu vào:
width = 3
height = 5
Kết quả mong đợi:
expected = 16
Đầu vào:
long long width = 3;
long long height = 5;
Kết quả mong đợi:
long long expected = 16;
Đầu vào:
long width = 3;
long height = 5;
Kết quả mong đợi:
long expected = 16;
Giải thích
Two sides of 3 and two sides of 5: 3 + 3 + 5 + 5 = 16.
Đầu vào:
width = 7
height = 7
Kết quả mong đợi:
expected = 28
Đầu vào:
long long width = 7;
long long height = 7;
Kết quả mong đợi:
long long expected = 28;
Đầu vào:
long width = 7;
long height = 7;
Kết quả mong đợi:
long expected = 28;
Giải thích
A square is a rectangle too: 4 × 7 = 28.
Tham khảo
Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.