当前位置: 首页 > news >正文

音响网站模板网页加速器免费永久

音响网站模板,网页加速器免费永久,网站绑定公众号,深圳石岩建网站#x1f383;个人专栏#xff1a; #x1f42c; 算法设计与分析#xff1a;算法设计与分析_IT闫的博客-CSDN博客 #x1f433;Java基础#xff1a;Java基础_IT闫的博客-CSDN博客 #x1f40b;c语言#xff1a;c语言_IT闫的博客-CSDN博客 #x1f41f;MySQL#xff1a… 个人专栏 算法设计与分析算法设计与分析_IT闫的博客-CSDN博客 Java基础Java基础_IT闫的博客-CSDN博客 c语言c语言_IT闫的博客-CSDN博客 MySQL数据结构_IT闫的博客-CSDN博客 数据结构​​​​​​数据结构_IT闫的博客-CSDN博客 CC_IT闫的博客-CSDN博客 C51单片机C51单片机STC89C516_IT闫的博客-CSDN博客 基于HTML5的网页设计及应用基于HTML5的网页设计及应用_IT闫的博客-CSDN博客​​​​​​ pythonpython_IT闫的博客-CSDN博客 离散数学离散数学_IT闫的博客-CSDN博客 欢迎收看希望对大家有用 问题一 给出下面的抽象基类container要求建立2个继承container的派生类Sphere与Cylinder,每一个派生类都包含虚函数surface_area()和 volume(),分别用来计算球体和圆柱体的表面积及体积。写出主程序应用C的多态性分别计算半径为5.0的球体以及半径为5.0和高为6.0的圆柱体的表面积和体积。问题一 问题二 已知一个有若干元素的数组arr使用函数模板求该数组的的最大值主函数定义数组使用模板函数求最大值并输出。 问题三 编写一个类模板对数组元素进行遍历输出、数组求和等主函数创建数组类对象调用函数遍历输出及求和。 答案一  #include iostreamusing namespace std;class Container { //声明抽象类containerprotected:double radius;public:Container(double _radius) { //抽象类container的构造函数radius_radius;}virtual double surface_area()0; //纯虚函数surface_areavirtual double volume()0; //纯虚函数volume};/****************************************************///派生类sphere pi3.14159 s4*pi*r*r v4/3*pi*r*r*rclass Sphere:public Container {public:Sphere(double _radius);double surface_area();double volume();};Sphere::Sphere(double _radius):Container(_radius) {}double Sphere::surface_area() {//s4*pi*r*rreturn 4*3.14159*radius*radius;}double Sphere::volume() {//v4/3*pi*r*r*rreturn 4.0/3*3.14159*radius*radius*radius;}/****************************************************///派生类Cylinderclass Cylinder:public Container {public:Cylinder(double _radius,double _height);double surface_area();double volume();private:double height;};Cylinder::Cylinder(double _radius,double _height):Container(_radius) {height_height;}double Cylinder::surface_area() {return 2*3.14159*radius*height2*3.14159*radius*radius;}double Cylinder::volume() {return 3.14159*radius*radius*height;;}int main() {Sphere sphere(2);cout球体表面积:sphere.surface_area()endl;cout球体体积:sphere.volume()endl;Cylinder Cylinder(2,3);cout圆柱体表面积:Cylinder.surface_area()endl;cout圆柱体体积:Cylinder.volume()endl;} 答案二 #include iostreamusing namespace std;/****************************************************///函数模板max_arr template class TT max_arr(T arr[],int n) {T maxarr[0];for(int i1; in; i)if(maxarr[i])maxarr[i];return max;}/****************************************************/int main() {int a[5],k;for(k0;k5;k)cina[k];coutmaxmax_arrint(a,5)endl;} 答案三 #include iostreamusing namespace std;templateclass T //类模板class Array {private:int _size;T* _ptr;public:Array(T arr[], int s);void show();T sum();};//构造函数templateclass TArrayT::Array(T arr[], int s) {_ptr new T[s];_size s;for (int i0; i_size; i) {_ptr[i]arr[i];}}//遍历输出函数templateclass Tvoid ArrayT::show() {for (int i0; i_size; i)cout*(_ptr i) ;coutendl;}/****************************************************///求和函数templateclass TT ArrayT::sum() {T s0;for (int i0; i_size; i)ss*(_ptr i);return s;}/****************************************************/int main() {int iArr[6] { 2, 1, 3, 5, 4, 6 };Arrayint a1(iArr, 6);a1.show();coutsuma1.sum()endl;return 0;}
http://www.yutouwan.com/news/283830/

相关文章:

  • 进不去wordpress北京搜索引擎优化
  • 会计公司网站源码淄博微网站建设
  • 哪些企业网站做得好泸州公司做网站
  • 源码网站代理伴奏在线制作网站
  • 公司建立自己的网站吗北京企业网站建设费用
  • 中介做哪些网站asp医院网站源码
  • 网站续费wordpress页面添加图片不显示图片
  • 网站强制使用极速模式百度风云榜
  • 濉溪建设投资网站传媒网站源码
  • 玉溪建设局门户网站泰安口碑好的企业建站公司
  • 微网站开发案例专业的会议网站建设
  • 免费发帖的网站wordpress 空间需求php哪个版本
  • 卧龙区网站建设页面推广文案模板
  • cms仿站教程瑞安建设网站
  • 学习电子商务网站建设与管理感想设计网红打卡
  • 公司网站海报怎么做1688黄页网品种大全2021
  • 一级做ae视频片段怎么做广州网站制作公司优化
  • 网站建设作业做一个简单的网站南阳做网站的
  • 统一手机网站和龙市建设局网站
  • 网站托管流程搜索关键词排名一般按照什么收费
  • 怎么做好营销型网站工程公司名字
  • 江西临川建设集团有限公司网站常用网站字体
  • 春哥技术团队网站建设wordpress建手机站
  • 长沙做网站哪个最好电商网页设计报价
  • 有网络网站打不开怎么回事啊新手搭建网站教程
  • 360网站兼容模式网站编辑培训学校
  • 清远市企业网站seo联系方式网站推广品牌
  • 网站名称没有排名网站开发百灵鸟优化
  • 天津免费建设网站宁波网站优化软件
  • 渭南建设工程招标投标网站wordpress靶机下载网站