|
发表于 2009-11-2 06:01:29
|
显示全部楼层
IP:江苏扬州
#include <stdio.h>
#include <math.h>
#include <conio.h>
int main (void)
{
double x1=1, y1=5, x2=4, y2=7, side1, side2, distance;
side1 = x2 - x1;
side2 = y2 - y1;
distance = sqrt(side1*side1 + side2*side2);
printf("the distance between the two points is:""%5.2f \n", distance);
getch();
return 0;
}
或者:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void)
{
double x1=1, y1=5, x2=4, y2=7, side1, side2, distance;
side1 = x2 - x1;
side2 = y2 - y1;
distance = sqrt(side1*side1 + side2*side2);
printf("the distance between the two points is:""%5.2f \n", distance);
system("pause");
return 0;
} |
|