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

正文內(nèi)容

面向?qū)ο蟪绦蛟O(shè)計(jì)答案-資料下載頁

2025-08-04 18:46本頁面
  

【正文】 (){ cout In Sub Class\n。 }}。void main(){ Base bc,*p。SubClass sc。p=amp。bc。 pfn()。p=amp。sc。 pfn()。}//In Base ClassIn Sub Class實(shí)現(xiàn)一個(gè)類A,在A中有兩個(gè)私有的整型變量a和b,定義構(gòu)造函數(shù)對(duì)a和b進(jìn)行初始化,并實(shí)現(xiàn)成員函數(shù)geta()取得a的值和getb()取b的值。實(shí)現(xiàn)類B從A繼承,覆蓋geta(),使其返回a的2倍。主函數(shù)中聲明類B對(duì)象,調(diào)用類B中的geta()并將結(jié)果輸出。include iostreamusing namespace std。class A{ private: int a。 int b。 public: A(int m,int n) {a=m。b=n。} int geta() {return a。} int getb() {return b。}}。class B :public A{ public: B(int m,int n):A(m,n){} int geta() {return A::geta()*2。}}。void main(){ B b(2,2)。 cout () endl。 return 0。}聲明抽象基類Shape,由它派生出3個(gè)派生類:Cirle(圓形)、Rectangle(矩形)、Triangle(三角形),用一個(gè)函數(shù)printArea分別輸出以上三者的面積,3個(gè)圖形的數(shù)據(jù)在定義對(duì)象是給定。include iostreamusing namespace std。//定義抽象基類Shapeclass Shape{public: virtual double area() const =0。 //純虛函數(shù)}。//定義Circle類class Circle:public Shape{public:Circle(double r):radius(r){} //結(jié)構(gòu)函數(shù) virtual double area() const {return *radius*radius。}。 //定義虛函數(shù) protected: double radius。 //半徑}。//定義Rectangle類class Rectangle:public Shape{public: Rectangle(double w,double h):width(w),height(h){} //結(jié)構(gòu)函數(shù) virtual double area() const {return width*height。} //定義虛函數(shù) protected: double width,height。 //寬與高}。class Triangle:public Shape{public: Triangle(double w,double h):width(w),height(h){} //結(jié)構(gòu)函數(shù) virtual double area() const {return *width*height。} //定義虛函數(shù) protected: double width,height。 //寬與高}。//輸出面積的函數(shù)void printArea(const Shape amp。s){cout()endl。} //輸出s的面積int main(){ Circle circle()。 //建立Circle類對(duì)象circle coutarea of circle =。 printArea(circle)。 //輸出circle的面積 Rectangle rectangle(,)。 //建立Rectangle類對(duì)象rectangle coutarea of rectangle =。 printArea(rectangle)。 //輸出rectangle的面積 Triangle triangle(,)。 //建立Triangle類對(duì)象 coutarea of triangle =。 printArea(triangle)。 //輸出triangle的面積 return 0。}實(shí)驗(yàn)八 輸入輸出流和C++工具一、實(shí)驗(yàn)?zāi)康纳钊肜斫釩++的輸入輸出的含義與其實(shí)現(xiàn)方法,掌握標(biāo)準(zhǔn)輸入輸出流的應(yīng)用,包括格式輸入輸出。學(xué)會(huì)使用C++的異常處理機(jī)制進(jìn)行程序的調(diào)試。二、實(shí)驗(yàn)要求輸入三角形的三邊a,b,c,計(jì)算三角形的面積的公式是area=s=構(gòu)成三角形的條件是:a+bc, b+ca, c+ab編寫程序,輸入a,b,c,檢查a,b,c是否滿足以上條件,如不滿足,由cerr輸出有關(guān)出錯(cuò)信息。include iostreaminclude cmathusing namespace std。int main(){double a,b,c,s,area。 coutplease input a,b,c:。 cinabc。 if (a+b=c) cerra+b=c,error!endl。 else if(b+c=a) cerrb+c=a,error!endl。 else if (c+a=b) cerrc+a=b,error!endl。 else {s=(a+b+c)/2。 area=sqrt(s*(sa)*(sb)*(sc))。 coutarea=areaendl。} return 0。}編程序,在顯示屏上顯示一個(gè)由字母B組成的三角形。include iostreaminclude iomanipusing namespace std。int main(){ for(int n=1。n8。n++) coutsetw(20n)setfill(39。 39。) setw(2*n1)setfill(39。B39。)Bendl。 return 0。}求一元二次方程式ax2+bx+c=0的實(shí)根,如果方程沒有實(shí)根,則輸出有關(guān)警告信息。include iostreaminclude using namespace std。int main(){float a,b,c,disc。 coutplease input a,b,c:。 cinabc。 if (a==0) cerra is equal to zero,error!endl。 else if ((disc=b*b4*a*c)0) cerrdisc=b*b4*a*c0endl。 else {coutx1=(b+sqrt(disc))/(2*a)endl。 coutx2=(bsqrt(disc))/(2*a)endl。 } return 0。}
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1