主题:帮帮我
帮帮忙,我是新手,不知道我编的程序哪里错了,可能听多错误的帮忙呀。谢谢#include <iostream.h>
struct F
{float r,i;};
void CreateF(struct F s)
{
cout<<"此复数为:";
if(s.r==0&&s.i!=0)
cout<<s.i<<"i"<<endl;
else if(s.r!=0&&s.i==0)
cout<<s.real<<endl;
else if(s.r==0&&s.i==0)
cout<<"0"<<endl;
else cout<<s.r<<"+("<<s.i<<"i)"<<endl;
}
void AddF(struct F s1,struct F s2,struct F s3)
{cin>>s1.r>>s1.i>>s2.r>>s2.i;
s3.r=s1.r+s2.r;
s3.i=s1.i+s2.i;
CreateF(struct F s3);
}
void SubF(struct F s1,struct F s2,struct F s3)
{cin>>s1.r>>s1.i>>s2.r>>s2.i;
s3.r=s1.r-s2.r;
s3.i=s1.i-s2.i;
CreateF(struct F s3);
}
void MultF(struct F s1,struct F s2,struct F s3)
{cin>>s1.r>>s1.i>>s2.r>>s2.i;
s3.r=s1.r*s2.r-s1.i*s2.i;
s3.i=s1.r*s2.i+s1.i*s2.r;
CreateF(struct F s3);
}
void SeparateReal(struct F s)
{cin>>s.r>>s.i;
cout<<"复数"<<s.r<<"+("<<s.i<<"i)的实部是:"<<s.r<<endl;}
void SeparateImagine(struct F s)
{cin>>s.r>>s.i;
cout<<"复数"<<s.r<<"+("<<s.i<<"i)的虚部是:"<<s.i<<endl;}
void main()
{struct F s,s1,s2,s3;
cin>>s.r>>s.i;
CreateF(s);
AddF(s1,s2,s3);
Subf(s1,s2,s3);
MultF(s1,s2,s3);
SeparateReal(s1);
SeparateImagine(s1);
}
struct F
{float r,i;};
void CreateF(struct F s)
{
cout<<"此复数为:";
if(s.r==0&&s.i!=0)
cout<<s.i<<"i"<<endl;
else if(s.r!=0&&s.i==0)
cout<<s.real<<endl;
else if(s.r==0&&s.i==0)
cout<<"0"<<endl;
else cout<<s.r<<"+("<<s.i<<"i)"<<endl;
}
void AddF(struct F s1,struct F s2,struct F s3)
{cin>>s1.r>>s1.i>>s2.r>>s2.i;
s3.r=s1.r+s2.r;
s3.i=s1.i+s2.i;
CreateF(struct F s3);
}
void SubF(struct F s1,struct F s2,struct F s3)
{cin>>s1.r>>s1.i>>s2.r>>s2.i;
s3.r=s1.r-s2.r;
s3.i=s1.i-s2.i;
CreateF(struct F s3);
}
void MultF(struct F s1,struct F s2,struct F s3)
{cin>>s1.r>>s1.i>>s2.r>>s2.i;
s3.r=s1.r*s2.r-s1.i*s2.i;
s3.i=s1.r*s2.i+s1.i*s2.r;
CreateF(struct F s3);
}
void SeparateReal(struct F s)
{cin>>s.r>>s.i;
cout<<"复数"<<s.r<<"+("<<s.i<<"i)的实部是:"<<s.r<<endl;}
void SeparateImagine(struct F s)
{cin>>s.r>>s.i;
cout<<"复数"<<s.r<<"+("<<s.i<<"i)的虚部是:"<<s.i<<endl;}
void main()
{struct F s,s1,s2,s3;
cin>>s.r>>s.i;
CreateF(s);
AddF(s1,s2,s3);
Subf(s1,s2,s3);
MultF(s1,s2,s3);
SeparateReal(s1);
SeparateImagine(s1);
}