输入两个复数,判断这两个复数的模是否相等
定义一个比较复数的模的函数(模=复数实部与虚部的平方和的平方根) struct comp double compare(struct comp a, struct comp b) int main()
#include
#include
{
double x, y;
double m;
};
{
a.m = sqrt(a.x * a.x + a.y * a.y);
b.m = sqrt(b.x * b.x + b.y * b.y);
return (a.m - b.m);
}
{
struct comp s1, s2;
scanf("%lf%lf", &s1.x, &s1.y);
scanf("%lf%lf", &s2.x, &s2.y);
if (compare(s1,s2) == 0)
printf("Equal/n");
else
printf("Unequal/n");
return 0;
}
共有 0 条评论