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

乌海市网站建设_网站建设公司_MySQL_seo优化

国外网站建设品牌,宁波人流,开发一款软件要多少钱,山东电商网站建设#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博客 欢迎收看希望对大家有用 目录 第一题 第二题 第三题 答案 第一题 第二题 第三题 第一题 设计一个复数类Complex包含成员变量实部real和虚部imag运算符重载/-实现两个复数加、减的功能。在主函数里创建两个复数对象分别求两个复数的和与差在主函数里显示运算结果。效果如图 ​ 第二题 现有一学生类定义    class Student{          ……..       private: int _id;          string _name;          char *_addr;     }; 实现学生类的赋值运算符重载主函数调用赋值运算符并输出对象信息。 ​ 第三题 编写一个程序声明一个2行2列矩阵类Matrix重载运算符“”使之能用于矩阵的加法运算。重载流插入运算符“”和流提取运算符“”,使之能用于该矩阵的输入与输出。从键盘输入两个矩阵a和b求两个矩阵之和并输出。效果如图 答案 第一题 #include iostreamusing namespace std;class Complex {private:double real;double imag;public:Complex(double x0,double y0):real(x),imag(y) {}void show() const; //输出数据friend Complex operator(const Complex a1, const Complex a2) ; //重载为类的友元函数friend Complex operator-(const Complex a1, const Complex a2);//重载为类的友元函数};/******************************************************************/void Complex::show() const {if(imag0)coutrealimagiendl;elsecoutrealimagiendl;}Complex operator(const Complex a1,const Complex a2) {return Complex(a1.reala2.real,a1.imaga2.imag);}Complex operator-(const Complex a1,const Complex a2) {return Complex(a1.real-a2.real,a1.imag-a2.imag);}/******************************************************************/int main() {Complex c1(5.1,3.4);Complex c2(3.6,5.3);Complex c;coutc1:;c1.show();coutc2:;c2.show();cc1c2;cout c1c2:;c.show();cc1-c2;coutc1-c2:;c.show();return 0;} 第二题 #include iostream#include cstringusing namespace std;class Student {private:int _id;string _name;char *_addr;public:Student(int id,string name,const char *addr);Student();Student operator(Student stu);void show();};Student::Student() {}Student::Student(int id,string name,const char *addr) {/******************************************/ _idid;_namename;this-_addrnew char[strlen(addr)1];if(_addr) strcpy(_addr,addr);/******************************************/ }Student Student::operator(Student stu) {//注意深拷贝/******************************************/ _idstu._id;_namestu._name;_addrnew char[strlen(stu._addr)1];if(_addr) strcpy(_addr,stu._addr);return *this;/******************************************/ }void Student::show() {cout学号:_idendl;cout姓名:_nameendl;cout住址:_addrendl;}int main() {Student stu2,stu1(10001,zhangsan,luoyang);stu1.show();stu2stu1;stu2.show();return 0;} 第三题 #include iostream#include iomanipusing namespace std;class Matrix {private:int a[2][2];friend istream operator(istream is,Matrix _m);friend ostream operator(ostream os,Matrix _m);friend Matrix operator(const Matrix mat1,const Matrix mat2);};ostream operator(ostream os,Matrix _m) {//每个数4列 setw(4)for(int i0; i2; i) {for(int j0; j2; j)ossetw(4)_m.a[i][j];osendl;}return os;}/****************************************************/istream operator(istream is,Matrix _m) {for(int i0; i2; i)for(int j0; j2; j)is_m.a[i][j];return is;}Matrix operator(const Matrix mat1,const Matrix mat2) {Matrix mat;for(int i0; i2; i)for(int j0; j2; j) {mat.a[i][j]mat1.a[i][j]mat2.a[i][j];}return mat;}/****************************************************/int main() {Matrix m1,m2,m;coutinput matrix m1:endl;cinm1;coutinput matrix m2:endl;cinm2;mm1m2;coutoutput matrix m:endl;coutm;return 0;}
http://www.ihoyoo.com/news/109770.html

相关文章:

  • 嘉兴专业做网站网站建设详情报价
  • 高明网站设计微信开店小程序怎么弄
  • 网站怎么自适应屏幕大小国内搜索引擎有哪些
  • 手袋东莞网站建设溧阳网站建设报价
  • 温州网站建设wzwmwl简单个人网页模板
  • 容桂做外贸网站百度开户流程
  • 查企业资质上什么网站长沙网站建设公司联系方式
  • 如何选择五屏网站建设上哪儿找做网站
  • 上海建站资讯类似于拼多多的网站怎么做
  • python网站开发用什么网站交互式体验
  • 做网站的人会不会拿走我的网站网页制作个人简介页面模板
  • 兰州启点网站建设1g1m wordpress
  • 网站设计参考文献有哪些公司做营销型网站
  • 想自己做淘宝有什么网站吗搜索引擎营销的英文缩写
  • 网站建设的总结200字个体营业执照网上申请
  • 常见的cms网站程序有哪些南昌网站建设那家好
  • 企业建设网站的策划流程wordpress模板修改图片大小
  • 北京做网站电话的公司免费的视频网站推广软件
  • 18款禁用网站app入口网络优化论文
  • 无锡网站建设无锡速联科技竞价托管收费标准
  • 艾纳网站建设重庆网站外包
  • 网站建设与维护试卷成都专业网站营销
  • 做微商必会的软件网站设计的种类
  • 对于网站开发有什么要求做科学小制作的视频网站
  • 网站有pc站和手机站网站教育培训机构十大排名
  • 高仿做的最好的网站电子商务网站推广方法
  • 郑州 网站建设网站开发 印花税
  • 个人网站 icp 代理火车头7.6 wordpress发布模块
  • 海口网站优化站长百科 wordpress
  • server2008做DNS与网站素材图