#include<iostream>
using namespace std;
class Num
{
int real,imag;
public:
Num()
{
real=0;
imag=0;
}
Num(int i)
{
real=i;
imag=0;
}
Num(int a,int b)
{
real=a;
imag=b;
}
void add(Num c1, Num c2)
{
real = c1.real+c2.real;
imag = c1.imag+c2.imag;
}
void display()
{
cout<<real<<"+"<<imag<<"i";
}
};
int main()
{
int real,imag;
cout<<"\nEnter the 1st real and imaginery number : ";
cin>>real>>imag;
Num n1(real,imag);
cout<<"\nEnter the 2nd real and imaginery number : ";
cin>>real>>imag;
Num n2(real,imag);
Num n3;
n3.add(n1,n2);
cout<<"\nThe sum is : ";
n3.display();
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpjbGFzcyBOdW0KewogICAgaW50IHJlYWwsaW1hZzsKICAgIHB1YmxpYzoKICAgIE51bSgpCiAgICB7CiAgICAgICAgcmVhbD0wOwogICAgICAgIGltYWc9MDsKICAgIH0KICAgIE51bShpbnQgaSkKICAgIHsKICAgICAgICByZWFsPWk7CiAgICAgICAgaW1hZz0wOwogICAgfQogICAgTnVtKGludCBhLGludCBiKQogICAgewogICAgICAgIHJlYWw9YTsKICAgICAgICBpbWFnPWI7CiAgICB9CiAgICB2b2lkIGFkZChOdW0gYzEsIE51bSBjMikKICAgIHsKICAgICAgICByZWFsID0gYzEucmVhbCtjMi5yZWFsOwogICAgICAgIGltYWcgPSBjMS5pbWFnK2MyLmltYWc7CiAgICB9CiAgICB2b2lkIGRpc3BsYXkoKQogICAgewogICAgICAgIGNvdXQ8PHJlYWw8PCIrIjw8aW1hZzw8ImkiOwogICAgfQp9OwoKaW50IG1haW4oKQp7CiAgICBpbnQgcmVhbCxpbWFnOwogICAgY291dDw8IlxuRW50ZXIgdGhlIDFzdCByZWFsIGFuZCBpbWFnaW5lcnkgbnVtYmVyIDogIjsKICAgIGNpbj4+cmVhbD4+aW1hZzsKICAgIE51bSBuMShyZWFsLGltYWcpOwoKICAgIGNvdXQ8PCJcbkVudGVyIHRoZSAybmQgcmVhbCBhbmQgaW1hZ2luZXJ5IG51bWJlciA6ICI7CiAgICBjaW4+PnJlYWw+PmltYWc7CiAgICBOdW0gbjIocmVhbCxpbWFnKTsKCiAgICBOdW0gbjM7CiAgICBuMy5hZGQobjEsbjIpOwogICAgY291dDw8IlxuVGhlIHN1bSBpcyA6ICI7CiAgICBuMy5kaXNwbGF5KCk7CgogICAgcmV0dXJuIDA7Cn0K