文章

11

粉丝

0

获赞

8

访问

356

头像
复数相加 题解:
P1438 北京理工大学机试题
发布于2026年3月9日 16:39
阅读数 48

#include <bits/stdc++.h>
using namespace std;

class Complex {
private:
    int a, b;
public:
    Complex():a(0),b(0){}
    Complex(int aa, int bb):a(aa), b(bb) {}
    Complex operator+(const Complex com) {
        return Complex(a + com.a, b + com.b);
    }
    int get_a() const {
        return a;
    }
    int get_b() const {
        return b;
    }
};

int main() {
    int n;
    while (cin >> n && n > 0) {
        int a1, b1, a2, b2;
        while (n--) {
            cin >> a1 >> b1 >> a2 >> b2;
            Complex c1(a1, b1);
            Complex c2(a2, b2);
            Complex c ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发