AcWing 3566. 复数加法
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 1e6 + 10;
int t, n, m, k, l, r, op, xx1, yy1, xx2, yy2;
int f[N];
bool flag;
struct myComplex {
int _a, _b;
myComplex(int a, int b): _a(a), _b(b) {};
myComplex operator+(const myComplex&com)const {
return myComplex(_a + com._a, _b + com._b);
}
void print() {
cout << _a;
if (_b >= 0) {
cout << "+";
}
cout << _b;
cout << "i";
cout << "\n";
}
};
void solve() {
cin >> t;
while (t--) {
cin >> xx1 >> yy1 >> xx2 >> yy2;
myComplex c1(xx1, yy1), c2(xx2, yy2);
(c1 + c2).print();
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}