#include <stdio.h>
struct complex{
int real;
int imag;
};//結(jié)構(gòu)體定義:分為實部和虛部
struct complex multiply(struct complex x, struct complex y);
//函數(shù)聲明
int main()
{
struct complex product, x, y;
scanf("%d%d%d%d", &x.real, &x.imag, &y.real, &y.imag);//輸入倆實部和虛部
product = multiply(x, y);//使用函數(shù)返回復數(shù)計算的結(jié)果
printf("(%d+%di) * (%d+%di) = %d + %di\n",
x.real, x.imag, y.real, y.imag, product.real, product.imag);
return 0;
}
struct complex multiply(struct complex x, struct complex y){
struct complex res;
res.real=x.real*y.real-x.imag*y.imag;
res.imag=x.real*y.imag+x.imag*y.real;
return res;
}
#include <stdio.h>
#include <math.h>
struct point {
double x, y, z;
};
void read_point(struct point *p);
double distance(struct point a, struct point b);
int main(void)
{
struct point p1, p2;
read_point(&p1);
read_point(&p2);
printf("%f\n", distance(p1, p2));
return 0;
}
void read_point(struct point *p)
{
scanf("%lf %lf %lf", &p->x, &p->y, &p->z);
}
// 計算并返回平面上兩點 a 和 b 之間的歐氏距離
double distance(struct point a, struct point b){
double res;
res=pow((a.x-b.x),2)+pow((a.y-b.y),2)+pow((a.z-b.z),2);
res=sqrt(res);
return res;
}