Problem D 從點到面

2021-07-31 11:36:09 字數 1435 閱讀 6708

home

web board

problemset

standing

status

statistics

time limit: 1 sec  

memory limit: 128 mb

submit: 1867  

solved: 1144 [

submit][

status][

web board]

乙個矩形可以由左上角和右下角的頂點而唯一確定。現在請定義兩個類:point和rectangle。

其中point類有x和y兩個屬性(均為int型別),表示二維空間內乙個點的橫縱座標,並具有相應的建構函式、析構函式和拷貝建構函式。此外,還有getx()和gety()方法用以得到乙個點的座標值。

rectangle類有lefttop和rightbottom兩個屬性(均為point類的物件),表示乙個矩形的左上角和右下角的兩個點,並具有相應的建構函式、析構函式。此外,還有getlefttop()、getrightbottom()方法用於獲取相應的左上角點、右下角點,getarea()方法用以獲取面積。

輸入有多行。

第一行是乙個正整數m,表示後面有m個測試用例。

每個測試用例佔一行,包括4個正整數,分別為左上角的橫座標、縱座標,右下角的橫座標、縱座標。

注意:1.請根據輸出樣例判斷兩個類中相應方法的書寫方法。

2. 假定螢幕的左下角為座標原點。

輸出見樣例。

110 10 20 0

a point (10, 10) is created!a point (20, 0) is created!a rectangle (10, 10) to (20, 0) is created!area: 100left top is (10, 10)a point (20, 0) is copied!a point (20, 0) is copied!right bottom is (20, 0)a point (20, 0) is erased!a point (20, 0) is erased!a rectangle (10, 10) to (20, 0) is erased!a point (20, 0) is erased!a point (10, 10) is erased!

[ submit][

status][

web board]

한국어<  

中文فارسی

english

ไทย 2003-2011 hustoj project team

anything about the problems, please contact admin:admin

#include #include using namespace std;

class point

return 0;

}

Problem D 從點到面

time limit 1 sec memory limit 128 mb submit 1011 solved 633 submit status web board 乙個矩形可以由左上角和右下角的頂點而唯一確定。現在請定義兩個類 point和rectangle。其中point類有x和y兩個屬性 均...

Problem D 從點到面

time limit 1 sec memory limit 128 mb submit 1029 solved 643 submit status web board 乙個矩形可以由左上角和右下角的頂點而唯一確定。現在請定義兩個類 point和rectangle。其中point類有x和y兩個屬性 均...

Problem D 從點到面

乙個矩形可以由左上角和右下角的頂點而唯一確定。現在請定義兩個類 point和rectangle。其中point類有x和y兩個屬性 均為int型別 表示二維空間內乙個點的橫縱座標,並具有相應的建構函式 析構函式和拷貝建構函式。此外,還有getx 和gety 方法用以得到乙個點的座標值。rectangl...