资源描述:
《c语言程序设计实验课1》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、C语言程序设计实验课1//Clanguageprogramdesignexperimentcourse1.cpp:entrancepointconsoleapplication.//designcanbeacomplexoperationdemonstrationprogram//[basicrequirements.//implementationofsixbasicoperations:(//l)acomplexnumberisgeneratedfromtherealandimaginarypartsofthein
2、put://2)sumoftwocomplexnumbers(//3)twocomplexdifference//4)twocomplexquadrature(//5)separatingtherealpartfromtheknowncomplexnumber//6)theimaginarypartisseparatedfromtheknowncomplexnumber#inelude"stdafx・#include//thedefinitionofcomplexstructureTypedefstr
3、uctFloatRealpart;FloatImagepart:}Complex;Theconstructionofcomplexfunctiondefinition//Complexgouzaofushu(float,x,float,y)VoidShuchu(float,Real,float,Image);Printf(〃isbuildingcomplexnumbersa,/);Complexz;Z.Realpart二x;Z.Imagepart二y;Printf(〃complexconstruction
4、issuccessful"!aPrintf(〃,youconstructcomplexnumbers:%.2f+%・2fi〃,〃z.Realpart",〃z.Imagepart");Returnz;//sumComplexQiuhe(Complex,Zl,Complex,Z2)Complexz3;VoidShuchu(float,Real,float,Image);Printf(〃isaskingfor・・・〃);Z3・Realpart二zl.Realpart+z2・Realpart;Z3・I
5、magepart二zl・Imagepart+z2.Imagepart;Printf(〃summationsuccess"!〃“;Printf(thecomplexnumberaftersumis:a);Shuchu(z3・Realpart,z3・Imagepart);Returnz3;//differeneeComplexQiucha(ComplexZl,ComplexZ2)//zlZ2issubtrahendminuend;VoidShuchu(float,Real,float,Image);C
6、omplexz3;Printf(〃ismakingadifference.・・,z);Z3・Realpart二zl.Realpart-z2・Realpart;Z3.Imagepart-zl・Imagepart-z2.Imagepart;Printf(〃rTdifferentialsuccess!“〃;Printf(thepluralnumberafterdifferenceis:a.);Shuchu(z3.Realpart,z3・Imagepart);Returnz3;//quadrat
7、ureComplexQiuji(Complex,Zl,Complex,Z2)VoidShuchu(float,Real,float,Image);Complexz3;Printf(〃isinquadrature.・・〃);Z3・Realpart二zl.Realpart*z2・Realpart;Z3・Imagepart二zl.ImagepaTt*z2・ImagepaTt;Printf(quadraturesuccessful!〃“;Printf(thepluralnumberafterquad
8、ratureisa);Shuchu(z3・Realpart,z3・Imagepart);Returnz3;Therealpartoftheseparation//FloatShibu(Complexz)Printf(〃isseparatingtherealpart・・・,z);Printf(〃rTseparat