freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

c面向?qū)ο蟪绦蛟O(shè)計(jì)上機(jī)考試題庫(kù)(編輯修改稿)

2025-04-23 23:34 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 rage()。 private: float fScore[3]。 }。 float CStuScore::GetAverage() { return (float)((fScore[0] + fScore[1] + fScore[2])/)。 }void main(){ CStuScore one。 float a,b,c。 char Name[12]。 char StuNO[9]。cout姓名:。cinName。cout學(xué)號(hào):。cinStuNO。cout 成績(jī)1: 成績(jī)2: 成績(jī)3: \n。cinabc。(Name,StuNO,a,b,c)。()。cout平均成績(jī)?yōu)?()\n。cout總成績(jī)()\n。}18. 先建立一個(gè)Point(點(diǎn))類,包含數(shù)據(jù)成員x,y(坐標(biāo)點(diǎn))。以它為基類,派生出一個(gè)Circle(圓)類,增加數(shù)據(jù)成員r(半徑),再以Circle類為直接基類,派生出一個(gè)Cylinder(圓柱體)類,在增加數(shù)據(jù)成員h(高)。編寫(xiě)程序,重載運(yùn)算符“”和“”,使之能夠用于輸出以上類對(duì)象。include class Point{public: Point(float=0,float=0)。 void setPoint(float,float)。 float getX() const {return x。} float getY() const {return y。} friend ostream amp。 operator(ostream amp。,const Point amp。)。protected: float x,y。}。Point::Point(float a,float b){x=a。y=b。}void Point::setPoint(float a,float b){x=a。y=b。}ostream amp。 operator(ostream amp。output,const Point amp。p){output[,]endl。 return output。}class Circle:public Point{public: Circle(float x=0,float y=0,float r=0)。 void setRadius(float)。 float getRadius() const。 float area () const。 friend ostream amp。operator(ostream amp。,const Circle amp。)。 protected: float radius。}。Circle::Circle(float a,float b,float r):Point(a,b),radius(r){}void Circle::setRadius(float r){radius=r。}float Circle::getRadius() const {return radius。}float Circle::area() const{return *radius*radius。}ostream amp。operator(ostream amp。output,const Circle amp。c){outputCenter=[,], r=, area=()endl。 return output。}class Cylinder:public Circle{public: Cylinder (float x=0,float y=0,float r=0,float h=0)。 void setHeight(float)。 float getHeight() const。 float area() const。 float volume() const。 friend ostreamamp。 operator(ostreamamp。,const Cylinderamp。)。 protected: float height。}。Cylinder::Cylinder(float a,float b,float r,float h) :Circle(a,b,r),height(h){}void Cylinder::setHeight(float h){height=h。}float Cylinder::getHeight() const {return height。}float Cylinder::area() const{ return 2*Circle::area()+2**radius*height。}float Cylinder::volume() const{return Circle::area()*height。}ostream amp。operator(ostream amp。output,const Cylinderamp。 cy){outputCenter=[,], r=, h= \narea=(), volume=()endl。 return output。}int main(){Cylinder cy1(,10)。 cout\noriginal cylinder:\nx=(), y=(), r= (), h=()\narea=() , volume=()endl。 (15)。 ()。 (5,5)。 cout\nnew cylinder:\ncy1。 Point amp。pRef=cy1。 cout\npRef as a point:pRef。 Circle amp。cRef=cy1。 cout\ncRef as a Circle:cRef。 return 0。}19. 寫(xiě)一個(gè)程序,定義抽象類型Shape,由他派生三個(gè)類:Circle(圓形),Rectangle(矩形),Trapezoid(梯形),用一個(gè)函數(shù)printArea分別輸出三者的面積,3個(gè)圖形的數(shù)據(jù)在定義對(duì)象是給定。include iostreamusing namespace std。class Shape{public: virtual double area() const =0。 }。class Circle:public Shape{public:Circle(double r):radius(r){} virtual double area() const {return *radius*radius。}。 protected: double radius。 }。class Rectangle:public Shape{public: Rectangle(double w,double h):width(w),height(h){} virtual double area() const {return width*height。} protected: double width,height。 }。class Trapezoid:public Shape{public: Trapezoid(double w,double h,double len):width(w),height(h),length(len){} virtual double area() const {return *height*(width+length)。} protected: double width,height,length。 }。void printArea(const Shape amp。s){cout()endl。} int main(){ Circle circle()。 coutarea of circle =。 printArea(circle)。 Rectangle rectangle(,)。 coutarea of rectangle =。 printArea(rectangle)。 Trapezoid trapezoid(,)。 coutarea of trapezoid =。 printArea(trapezoid)。 return 0。}20. 定義一個(gè)人員類Cperson,包括數(shù)據(jù)成員:姓名、編號(hào)、性別和用于輸入輸出的成員函數(shù)。在此基礎(chǔ)上派生出學(xué)生類CStudent(增加成績(jī))和老師類Cteacher(增加教齡),并實(shí)現(xiàn)對(duì)學(xué)生和教師信息的輸入輸出。 include include class CPerson {public: void SetData(char *name, char *id, bool isman = 1) { int n = strlen(name)。 strncpy(pName, name, n)。 pName[n] = 39。\039。 n = strlen(id)。 strncpy(pID, id, n)。 pID[n] = 39。\039。 bMan = isman。 } void Output() { cout姓名:pNameendl。 cout編號(hào):pIDendl。 char *str = bMan?男:女。 cout性別:strendl。 }private: char pName[20]。 char pID[20]。 bool bMan。 }。class CStudent: public CPerson {public: void InputScore(double score1, double score2, double score3) { dbScore[0] = score1。 dbScore[1] = score2。 dbScore[2] = score3。 } void Print() { Output()。 for (int i=0。 i3。 i++) cout成績(jī)i+1:dbScore[i]endl。 }private: double dbScore[3]。 }。class Cteacher: public CPerson {public: void Inputage(double age) { tage = age。 } void Print() { Output()。 cout教齡:tageendl。 }private: double tage。 }。void main() { CStudent stu。 Cteacher tea。 (LiMing, 21010211)。 ( 80, 76, 91 )。 ()。 (zhangli,001)。 (12)。 ()。}二、第二類題目(20道,每題9分,請(qǐng)自行設(shè)計(jì)輸出格式)1.某商店經(jīng)銷一種貨物,貨物成箱購(gòu)進(jìn),成箱賣出,購(gòu)進(jìn)和賣出時(shí)以重量為單位,各箱的重量不一樣,因此,商店需要記下目前庫(kù)存貨物的總量,要求把商店貨物購(gòu)進(jìn)和賣出的情況模擬出來(lái)。includeiostreamusing namespace std。class Goods{ public : Goods ( int w) { weight = w。 totalWeight += w 。 } 。 ~ Goods
點(diǎn)擊復(fù)制文檔內(nèi)容
黨政相關(guān)相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1