【C语言】复数运算

#include
void main(){
	struct complex{
		float sb;
		float xb;
	}b1,b2,b3,b4,b5;
	scanf("%f%f%f%f",&(b1.sb),&(b1.xb),&(b2.sb),&(b2.xb));
	b3.sb=b1.sb+b2.sb;
	b3.xb=b1.xb+b2.xb;
	b4.sb=b1.sb-b2.sb;
	b4.xb=b1.xb-b2.xb;
	b5.sb=b1.sb*b2.sb-b1.xb*b2.xb;
	b5.xb=b1.sb*b2.xb+b1.xb*b2.sb;
	if(b3.xb>0)
	printf("%.2f+%.2fi",b3.sb,b3.xb);
	else if(b3.xb<0)
	printf("%.2f%.2fi",b3.sb,b3.xb);
	else printf("%.2f",b3.sb);
	printf("  ");
	if(b4.xb>0)
	printf("%.2f+%.2fi",b4.sb,b4.xb);
	else if(b4.xb<0)
	printf("%.2f%.2fi",b4.sb,b4.xb);
	else printf("%.2f",b4.sb);
	printf("  ");
	if(b5.xb>0)
	printf("%.2f+%.2fi",b5.sb,b5.xb);
	else if(b3.xb<0)
	printf("%.2f%.2fi",b5.sb,b5.xb);
	else printf("%.2f",b5.sb);
	printf("  ");}

你可能感兴趣的:(c语言,开发语言)