日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

项目四

發布時間:2024/1/8 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 项目四 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/* * Copyright (c) 2011, 煙臺大學計算機學院 * All rights reserved. * 作 者:王靜 * 完成日期:2013 年 5 月 21 日 * 版 本 號:v1.0 * 輸入描述: * 問題描述: * 程序輸出: * 問題分析: * 算法設計:略 */ #include<iostream> #include<Cmath> #define pi 3.14 using namespace std; class Point //定義坐標點類 { public:Point():x(0),y(0) {};Point(double x0, double y0):x(x0), y(y0) {};//void PrintPoint();friend ostream&operator<<(ostream&,Point&);double x,y; //數據成員,表示點的橫坐標和縱坐標 }; ostream&operator<<(ostream&cout,Point&c) {cout<<"("<<c.x<<","<<c.y<<")"; //輸出點return cout; } class Circle: public Point //利用坐標點類定義直線類, 其基類的數據成員表示直線的中點 { public:Circle():oo(0,0),r(1){};Circle(double x0,double y0,double r0):oo(x0,y0),r(r0){};friend ostream&operator<<(ostream&,Circle&);//void PrintCircle();double arge();double circle();double r;Point oo; }; double Circle::arge() {return pi*r*r; } double Circle::circle() {return 2*pi*r; }//void Circle::PrintCircle()ostream&operator<<(ostream&cout,Circle&c){cout<<"圓心為:"<<c.oo;//oo.PrintPoint();cout<<"半徑是:"<<c.r<<"的圓";return cout;}class Cylinder:public Circle{public:Cylinder():cc(0,0,1),h(1){};Cylinder(double x0,double y0,double r0,double h0):cc(x0,y0,r0),h(h0){};//void PrintCylinder();friend ostream&operator<<(ostream&,Cylinder&);double cylindervirmle();double cylinderarge();private:double h;Circle cc;};double Cylinder::cylindervirmle(){return h*cc.arge();}double Cylinder::cylinderarge(){return h*cc.circle()+cc.arge()*2;}//void Cylinder::PrintCylinder()ostream&operator<<(ostream&cout,Cylinder&c){cout<<"底面為:"<<c.cc;//cc.PrintCircle();cout<<"高為:"<<c.h<<"的圓柱體的";cout<<"表面積為:"<<c.cylinderarge();cout<<"體積為:"<<c.cylindervirmle()<<endl;return cout;} int main() {Cylinder c(1,1,2,4);cout<<c;return 0; }



?運行結果:

總結

以上是生活随笔為你收集整理的项目四的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。