第四章T5
来源:互联网 发布:电子书软件iphone 编辑:程序博客网 时间:2024/04/29 20:51
#include <iostream.h>
//using namespace std;
class Matrix
{public:
Matrix();
friend Matrix operator+(Matrix &,Matrix &);
friend ostream& operator<<(ostream&,Matrix&);
friend istream& operator>>(istream&,Matrix&);
private:
int mat[2][3];
};
Matrix::Matrix()
{for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
mat[i][j]=0;
}
Matrix operator+(Matrix &a,Matrix &b)
{Matrix c;
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
{c.mat[i][j]=a.mat[i][j]+b.mat[i][j];
}
return c;
}
istream& operator>>(istream &in,Matrix &m)
{cout<<"input value of matrix:"<<endl;
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
in>>m.mat[i][j];
return in;
}
ostream& operator<<(ostream &out,Matrix &m)
{for (int i=0;i<2;i++)
{for(int j=0;j<3;j++)
{out<<m.mat[i][j]<<" ";}
out<<endl;}
return out;
}
int main()
{ Matrix a,b,c;
cin>>a;
cin>>b;
cout<<endl<<"Matrix a:"<<endl<<a<<endl;
cout<<endl<<"Matrix b:"<<endl<<b<<endl;
c=a+b;
cout<<endl<<"Matrix c = Matrix a + Matrix b :"<<endl<<c<<endl;
return 0;
}
- 第四章T5
- 第四章t5
- 第三章习题T5
- 第六章T5
- 第七章T5
- t5
- T5 页面周期
- T5 Form 周期
- 作业0414 t5
- NOIP2016 T5 蚯蚓
- 第四章第四题
- 第四章第四题
- T5的页面生存周期
- T5独木舟上的旅行
- [百度之星复赛T5]
- Java 课下练习题 T5
- 第四章
- 第四章
- cout <<string对象 编译出错引发的思考
- 边缘检测后计算区域周长
- 华为oj之递推公式
- 基础教程第二课
- 黑马程序员——关于Java中变量的意义和注意事项
- 第四章T5
- 继承的学习1
- 关于startActivityForResult传值回原activity bundle是null的解决
- 分类改变
- 硕士小论文格式
- oracle表结构
- 网站优化文章写作的思路和流程是什么?
- 第三题
- Thinking In Java笔记(第三章 操作符)