7.12
来源:互联网 发布:联想售后系统优化 编辑:程序博客网 时间:2024/05/17 15:21
#include<iostream> #include<iomanip> using namespace std; class Matrix{ public: Matrix() {} ~Matrix(){} Matrix operator +(Matrix &); friend ostream& operator<<(ostream &output, Matrix &); friend istream& operator>>(istream &input, Matrix &); private: int m_[2][4]; };<span style="font-family: Arial, Helvetica, sans-serif;"> </span>
Matrix Matrix::operator+(Matrix &m) { Matrix m3; for (int i = 0; i < 2; i++) { for (int j = 0; j < 4; j++) m3.m_[i][j] = m_[i][j] + m.m_[i][j]; } return m3; } istream& operator>>(istream &input, Matrix &a) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 4; j++) cin >> a.m_[i][j]; } cout << endl; return input; } ostream& operator<<(ostream &output, Matrix &b) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 4; j++) cout <<setw(4)<< b.m_[i][j]; cout << endl; } cout << endl; return output; } int main() { Matrix m1; cout << "请输入m1矩阵" << endl; cin >> m1; cout << "m1矩阵显示:" << endl; cout << m1; Matrix m2; cout << "请输入m2矩阵" << endl; cin >> m2; cout << "m2矩阵显示:" << endl; cout << m2; Matrix M; cout << "m1矩阵和m2矩阵的和显示:" << endl; M = m1 + m2; cout << M; system("pause"); return 0; }
0 0
- 7.12
- 7.12
- 7.12
- 7.12
- 7.12
- 7.12
- 7.12
- 7.12
- 7.12.2008
- 6.26-7.12
- 7.12编译
- 作业7.12
- 7.12 练习
- 【日志7.12】
- 7.12编程练习
- 7.12事件和委托
- 汇编学习--7.12--总结
- 7.12 一些心得体会
- Oracle中drop user和drop user cascade的区别
- nexus私服搭建
- Linux Shell脚本查看NUMA信息
- CruiseYoung提供的带有详细书签的电子书籍目录
- C#中数组的空间分配问题
- 7.12
- foundation-NSNumber
- 开通博客了,记录下。。。
- Python的os.walk()方法详细讲解
- Linux杀死进程的方法
- Android异步加载图片与文字(一)
- 使用git curl服务测试-----Restful服务
- mtd-utils命令简介
- 8.17