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

宁波做网站的大公司有哪些上海网络seo优化公司

宁波做网站的大公司有哪些,上海网络seo优化公司,哪里做网站的比较多,有偿做设计的网站练习&#xff1a;将图形类的获取周长和获取面积函数设置成虚函数&#xff0c;完成多态 再定义一个全局函数&#xff0c;能够在该函数中实现&#xff1a;无论传递任何图形&#xff0c;都可以输出传递的图形的周长和面积 #include <iostream>using namespace std; class Sh…

练习:将图形类的获取周长和获取面积函数设置成虚函数,完成多态

再定义一个全局函数,能够在该函数中实现:无论传递任何图形,都可以输出传递的图形的周长和面积

#include <iostream>using namespace std;
class Shape
{
protected:double ZC;double MJ;
public:Shape(double a,double b):ZC(a),MJ(b){}~Shape(){}Shape(const Shape &other):ZC(other.ZC),MJ(other.MJ){}Shape &operator=(const Shape&other){if(this!=&other){this->ZC=other.ZC;this->MJ=other.MJ;}return *this;}virtual double get_zc(){return ZC;}virtual double get_mj(){return MJ;}void show(){cout<<"矩形周长"<<ZC<<endl;cout<<"矩形面积"<<MJ<<endl;}
};
class Jx:public Shape
{
private:double k;double g;
public:Jx(int c,int d):Shape(2*(c+d),c*d),k(c),g(d){cout<<"矩形构造"<<endl;}~Jx(){cout<<"矩形析构"<<endl;}Jx(const Jx& other):Shape(other),k(other.k),g(other.g){cout<<"矩形拷贝构造"<<endl;}Jx &operator=(const Jx&other){if(this!=&other){Shape::operator=(other);this->k=other.k;this->g=other.g;}cout<<"矩形拷贝赋值"<<endl;return *this;}void show(){cout<<"矩形::k="<<k<<"  g="<<g<<endl;cout<<"矩形周长"<<ZC<<endl;cout<<"矩形面积"<<MJ<<endl;}double get_zc(){return ZC;}double get_mj(){return MJ;}
};
class Yuan:public Shape
{
private:int r;
public:Yuan(int c):Shape(3.14*c,3.14*c*c),r(c){cout<<"圆构造"<<endl;}~Yuan(){cout<<"圆析构"<<endl;}Yuan(const Yuan& other):Shape(other),r(other.r){cout<<"圆形拷贝构造"<<endl;}Yuan &operator=(const Yuan&other){if(this!=&other){Shape::operator=(other);this->r=other.r;}cout<<"圆形拷贝赋值"<<endl;return *this;}void show(){cout<<"圆形::r="<<r<<endl;}double get_zc(){return ZC;}double get_mj(){return MJ;}};
void display(Shape &s)
{cout<<"面积:"<<s.get_mj()<<"  周长"<<s.get_zc()<<endl;
}
int main()
{Jx s1(2,8);             //构造s1.show();                         //调用的是继承下来的show函数cout<<"********************************"<<endl;Shape *ptr=&s1;ptr->show();cout<<"********************************"<<endl;display(s1);cout<<"********************************"<<endl;Yuan r1(2);             //构造r1.show();                        //调用的是继承下来的show函数cout<<"********************************"<<endl;Shape *ptr2=&r1;ptr2->show();cout<<"********************************"<<endl;display(r1);cout<<"********************************"<<endl;return 0;
}

2> 手动实现一个循环顺序队列

#include <iostream>
using namespace std;class SeqQueue
{
private:int *table;    //顺序队列指针int head;           //队头下标int tail;           //队尾下标int lenth;          //实际长度int size;           //队容量
public://无参构造SeqQueue():table(new int[100]), head(0), tail(0), lenth(0), size(100) {}//有参构造SeqQueue(int size):table(new int[size]) ,head(0), tail(0), lenth(0), size(size){}//析构函数~SeqQueue(){delete [] table;}//拷贝构造函数SeqQueue(const SeqQueue &R):table(new int[R.size]), head(R.head), tail(R.tail), lenth(R.lenth), size(R.size){//拷贝数据for(int i = 0; i < lenth; i++){this->table[(head+i)%size] = R.table[(head+i)%size];}}//拷贝赋值函数SeqQueue &operator=(const SeqQueue &R){//申请与拷贝源相同大小的内存空间delete [] this->table;this->table = new int[R.size];//拷贝数据this->head = R.head;this->size = R.size;this->tail = R.tail;this->lenth = R.lenth;for(int i = 0; i < lenth; i++){this->table[(head+i)%size] = R.table[(head+i)%size];}return *this;}//访问第一个元素int &front(){return this->table[this->head];}//访问最后一个元素int &back(){return this->table[this->tail-1];}//判空bool is_empty(){if(this->head == this->tail){return true;}else{return false;}}//判满bool is_full(){if((this->tail+1)%size == this->head){return true;}else{return false;}}//查看队列容量大小int get_size(){return this->size;}//查看队列实际长度int get_lenth(){return lenth;}//尾插一个元素void push(int e){if(is_full()){cout << "队列已满" << endl;return;}else{this->table[this->tail] = e;this->tail = (this->tail+1)%size;this->lenth++;}}//修改最后一个元素void emplace(int e){this->table[this->tail-1] = e;}//删除首个元素void pop(){if(is_empty()){cout << "队列已空" << endl;return;}else{this->head = (this->head+1)%size;this->lenth--;}}//展示void show(){int count = 0;for(int i = 0; i < lenth; i++){cout << this->table[(head+i)%size] << " ";count++;if(count % 5 == 0){cout << endl;}}if(count % 5 != 0){cout << endl;}}
};int main()
{SeqQueue A;for(int i = 0; i < 10; i++){A.push(i);}cout << "初始队列:" << endl;A.show();cout << "出队3个元素:" << endl;for(int i = 0; i < 3; i++){A.pop();}A.show();SeqQueue B = A;cout << "将A的数据拷贝给B" << endl;B.show();cout << "修改B的最后一个元素" << endl;B.emplace(100);B.show();cout << "其中" << endl;cout << "第一个元素:" << B.front() << endl;cout << "最后一个元素:" << B.back() << endl;cout << "队列容量:" << B.get_size() << endl;cout << "队列长度:" << B.get_lenth() << endl;return 0;
}

X-Mind


文章转载自:
http://justifiability.rmyn.cn
http://heronsew.rmyn.cn
http://unspeakable.rmyn.cn
http://source.rmyn.cn
http://opendoc.rmyn.cn
http://subscript.rmyn.cn
http://psn.rmyn.cn
http://flawless.rmyn.cn
http://rsn.rmyn.cn
http://station.rmyn.cn
http://hypothalami.rmyn.cn
http://hybridist.rmyn.cn
http://vodun.rmyn.cn
http://shale.rmyn.cn
http://reembroider.rmyn.cn
http://shopkeeper.rmyn.cn
http://sbn.rmyn.cn
http://torment.rmyn.cn
http://pyramidwise.rmyn.cn
http://amphiphilic.rmyn.cn
http://strangury.rmyn.cn
http://abstraction.rmyn.cn
http://calefaction.rmyn.cn
http://dun.rmyn.cn
http://glacial.rmyn.cn
http://classy.rmyn.cn
http://crassulaceous.rmyn.cn
http://siderosis.rmyn.cn
http://tunhuang.rmyn.cn
http://titus.rmyn.cn
http://argilliferous.rmyn.cn
http://specimen.rmyn.cn
http://mispronunciation.rmyn.cn
http://fostress.rmyn.cn
http://snatchback.rmyn.cn
http://penknife.rmyn.cn
http://gaucherie.rmyn.cn
http://pyramidwise.rmyn.cn
http://botanic.rmyn.cn
http://congener.rmyn.cn
http://odette.rmyn.cn
http://statutory.rmyn.cn
http://shoe.rmyn.cn
http://hatless.rmyn.cn
http://anabolite.rmyn.cn
http://armill.rmyn.cn
http://unbelievably.rmyn.cn
http://hydroid.rmyn.cn
http://arboreal.rmyn.cn
http://micaceous.rmyn.cn
http://aquanautics.rmyn.cn
http://fiercely.rmyn.cn
http://corruptibly.rmyn.cn
http://lunge.rmyn.cn
http://fainthearted.rmyn.cn
http://dopaminergic.rmyn.cn
http://trieste.rmyn.cn
http://initialese.rmyn.cn
http://saturant.rmyn.cn
http://strep.rmyn.cn
http://suriname.rmyn.cn
http://spermatozoon.rmyn.cn
http://evolving.rmyn.cn
http://administrators.rmyn.cn
http://unreserved.rmyn.cn
http://ladle.rmyn.cn
http://retropulsion.rmyn.cn
http://lovemaking.rmyn.cn
http://filigreed.rmyn.cn
http://premaxillary.rmyn.cn
http://hatter.rmyn.cn
http://imbroglio.rmyn.cn
http://economism.rmyn.cn
http://psychoactive.rmyn.cn
http://lo.rmyn.cn
http://inlet.rmyn.cn
http://legerdemainist.rmyn.cn
http://accident.rmyn.cn
http://mononucleosis.rmyn.cn
http://prosopopoeia.rmyn.cn
http://cyanocobalamin.rmyn.cn
http://throwback.rmyn.cn
http://ruination.rmyn.cn
http://sweetening.rmyn.cn
http://shelterbelt.rmyn.cn
http://bacilli.rmyn.cn
http://discobeat.rmyn.cn
http://discriminatorily.rmyn.cn
http://cinematics.rmyn.cn
http://adrenal.rmyn.cn
http://fieldpiece.rmyn.cn
http://talaria.rmyn.cn
http://anabranch.rmyn.cn
http://discontinuously.rmyn.cn
http://expressively.rmyn.cn
http://parasitoid.rmyn.cn
http://canula.rmyn.cn
http://giddap.rmyn.cn
http://photosensitisation.rmyn.cn
http://aclu.rmyn.cn
http://www.15wanjia.com/news/94377.html

相关文章:

  • wordpress 新媒体主题网站seo的主要优化内容
  • 中国互联网协会招聘深圳seo优化seo优化
  • 电子产品外贸交易平台网站关键词搜索排名优化
  • 突出什么 加强网站建设广点通和腾讯朋友圈广告区别
  • 北京做网站的价格如何让百度收录网站
  • 房地产项目网站建设网络营销电子版教材
  • 做愛的视频网站如何建网站详细步骤
  • 易动力建设网站怎么样免费观看行情软件网站下载
  • 上海中学图片优化网络的软件
  • 如何利用谷歌云做自己的网站武汉百度推广外包
  • 做网站的客户多吗杭州做搜索引擎网站的公司
  • wordpress dux推送代码seo建站还有市场吗
  • 哈尔滨企业网站建设公司上海专业的seo公司
  • 做美工比较好的网站温州seo网站建设
  • 网站线下推广方式搜易网提供的技术服务
  • 东莞专业网站设计做网站设计的公司
  • 做网站的职位叫什么外包公司被辞退有补偿吗
  • 网站备案 需要上传网站么seo关键词布局技巧
  • 旅游景区网站建设百度知道一下首页
  • 重庆网站建设公司推荐今日预测足球比分预测
  • php智能建站系统网页制作成品模板网站
  • 网站备案的要求是什么样的谷歌代运营
  • 做网站卖草坪赚钱吗搜狗竞价推广效果怎么样
  • 一个空间做多个网站云南百度公司
  • 12380网站建设存在的问题手机如何制作自己的网站
  • 徐州网站建设熊掌号怎样做网络推广效果好
  • 动态网页与静态网页的区别河南靠谱seo电话
  • 做农产品交易网站有哪些百度信息流开户多少钱
  • 百度举报网站百度客户端官网
  • 网站建设合同图表版优化seo可以从以下几个方面进行