个人作业
来源:互联网 发布:mac windows截屏 编辑:程序博客网 时间:2024/05/17 03:43
#include<iostream>
#include<string>
using namespace std;
class jz;
istream &operator >> (istream &is,jz &c);
ostream &operator << (ostream &os,jz &c);
class jz{
public:
jz(){};
friend jz operator + (const jz &a, const jz &b); //friend
friend ostream &operator << (ostream &,jz &);
friend istream &operator >> (istream &,jz &);
jz(int a,int b,int c,int d,int e,int f) {d1=a;d2=b;d3=c;d4=d;d5=e;d6=f;}
private:
int d1,d2,d3,d4,d5,d6;
};
ostream & operator << (ostream &output,jz &c)
{
output << c.d1 << " " << c.d2 <<" " << c.d3 <<endl;
cout << c.d4 << " " << c.d5 <<" " << c.d6 <<endl;
return output;
}
istream & operator >> (istream &input,jz &c)
{
input>> c.d1 >> c.d2 >> c.d3 >> c.d4 >> c.d5 >> c.d6;
return input;
}
jz operator + (const jz &a, const jz &b)
{
int a1=a.d1+b.d1;
int a2=a.d2+b.d2;
int a3=a.d3+b.d3;
int a4=a.d4+b.d4;
int a5=a.d5+b.d5;
int a6=a.d6+b.d6;
return jz(a1,a2,a3,a4,a5,a6);
}
int main()
{
jz a,b,c;
cout << "Please input six number to jz1:"<< endl;
cin >> a;
cout << "Please input six number to jz2:"<< endl;
cin >> b;
c=a+b;
cout << "c=a+b" <<endl;
cout << c <<endl;
return 0;
}
#include<string>
using namespace std;
class jz;
istream &operator >> (istream &is,jz &c);
ostream &operator << (ostream &os,jz &c);
class jz{
public:
jz(){};
friend jz operator + (const jz &a, const jz &b); //friend
friend ostream &operator << (ostream &,jz &);
friend istream &operator >> (istream &,jz &);
jz(int a,int b,int c,int d,int e,int f) {d1=a;d2=b;d3=c;d4=d;d5=e;d6=f;}
private:
int d1,d2,d3,d4,d5,d6;
};
ostream & operator << (ostream &output,jz &c)
{
output << c.d1 << " " << c.d2 <<" " << c.d3 <<endl;
cout << c.d4 << " " << c.d5 <<" " << c.d6 <<endl;
return output;
}
istream & operator >> (istream &input,jz &c)
{
input>> c.d1 >> c.d2 >> c.d3 >> c.d4 >> c.d5 >> c.d6;
return input;
}
jz operator + (const jz &a, const jz &b)
{
int a1=a.d1+b.d1;
int a2=a.d2+b.d2;
int a3=a.d3+b.d3;
int a4=a.d4+b.d4;
int a5=a.d5+b.d5;
int a6=a.d6+b.d6;
return jz(a1,a2,a3,a4,a5,a6);
}
int main()
{
jz a,b,c;
cout << "Please input six number to jz1:"<< endl;
cin >> a;
cout << "Please input six number to jz2:"<< endl;
cin >> b;
c=a+b;
cout << "c=a+b" <<endl;
cout << c <<endl;
return 0;
}
0 0
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 个人作业
- 二分查找和未写完的归并查找 5.14
- hdu1828 Picture
- 第8周项目4-String类的构造
- 敏捷测试
- TP框架中D方法与M方法的区别
- 个人作业
- C++模板类代码只能写在头文件?
- 文件读写和链表插入删除显示 5.17
- 1041 : 国庆出游
- 第9周项目1-复数类中的运算符重载(续)
- LINUX下Socket编程 函数格式详解
- Objective-C中属性使用
- 学期前半段工作总结
- spring queryForList解析