文章
84
粉丝
408
获赞
33
访问
877.0k
#include<iostream>
using namespace std;
class CTriangle{
private:
int x, y;
public:
CTriangle(){}
CTriangle(int xx, int yy):x(xx),y(yy){}
~CTriangle(){}
CTriangle operator+(CTriangle c);
void display();
};
CTriangle CTriangle::operator+(CTriangle c)
{
CTriangle a;
a.x = x + c.x;
a.y = y + c.y;
return a;
}
void CTriangle::display()
{
cout << "A(0," << y << "),B(0,0),C(" << x << ",0)" << endl;
}
int main()
{
int x, y;
CTriangle a(0,0);
while (1) {
cin >> y;
if (y == 0)
break;
cin >> x;
CTriangle b(x,y);
a = a + b;
}
a.display();
return 0;
}
登录后发布评论
暂无评论,来抢沙发