Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<cmath>
- using namespace std;
- ifstream fin("complex.in");
- ofstream fout("complex.out");
- struct complex
- {
- double re,im;
- } z;
- void citire(struct complex &z)
- {
- fin>>z.re>>z.im;
- }
- void maxim(struct complex z1,struct complex z2)
- {
- double ma1=0,ma2=0;
- ma1+=sqrt((z1.re*z1.re)+(z1.im*z1.im));
- ma2+=sqrt((z2.re*z2.re)+(z2.im*z2.im));
- if(ma1>ma2)
- {
- fout<<z1.re;
- if(z1.im<0)
- {
- fout<<'-'<<z1.im;
- }
- else if(z1.im>=1)
- {
- fout<<'+'<<-z1.im;
- }
- }
- else
- {
- fout<<z2.re;
- if(z2.im<0)
- {
- fout<<'-'<<z2.im;
- }
- else if (z2.im>=1)
- {
- fout<<'+'<<z2.im;
- }
- }
- }
- int main()
- {
- complex z1,z2;
- citire(z1);
- citire(z2);
- maxim(z1,z2), fout<<"*i";
- fin.close();
- fout.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment