三维坐标求两点距离

简单粗暴点

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void main()
{ 
	double x1,y1,z1,x2,y2,z2;
	double leng,disn1,disn2,disn3;

	
	printf("输入两点的三维坐标:\n");
	printf("x1=");
	scanf("%lf",&x1); 
	printf("y1=");
	scanf("%lf",&y1); 
	printf("z1=");
	scanf("%lf",&z1);
	
	printf("\n");
	
	printf("x2=");
	scanf("%lf",&x2); 
	printf("y2=");
	scanf("%lf",&y2); 
	printf("z2=");
	scanf("%lf",&z2); 
	
	disn1 = (x1-x2)*(x1-x2);
	disn2 = (y1-y2)*(y1-y2);
	disn3 = (z1-z2)*(z1-z2);
	
	leng = sqrt(disn1 + disn2 + disn3);
	
	printf("两点的距离为%lf",leng);
}
    原文作者:暴富梦想家
    原文地址: https://blog.csdn.net/qq_38272075/article/details/105528598
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞