로딩
요청 처리 중입니다...

[c언어] 두 점 사이의 거리 구하기

 [c언어] 두 점 사이의 거리 구하기

제곱근을 구하는 함수인 sqrt를 사용해서 구하면 편리합니다. (double로 선언) #include #include int main() { double x1, y1, x2, y2; double distance; printf("Enter the coordinates of p.

\n"); scanf("%lf%lf", &x1, &y1); printf("Enter the coordinates of q.\n"); scanf("%lf%lf", &x2, &y2); distance = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)); printf("Distance between the points is %lf.

\n", distance); return 0; } 결과...