Posted in 面试题 onAugust 17, 2015
解:#include
#include
struct point
{
float x;
float y;
};
main()
{ float dis;
struct point pt1,pt2;
printf(“input point1.x:”);
scanf(“%f”,&pt1.x);
printf(“input point1.y:”);
scanf(“%f”,&pt1.y);
printf(“input point2.x:”);
scanf(“%f”,&pt2.x);
printf(“input point2.y:”);
scanf(“%f”,&pt2.y);
dis=sqrt((pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y));
printf(“The distance of the two points is:%f”,dis);
}
#include
struct point
{
float x;
float y;
};
main()
{ float dis;
struct point pt1,pt2;
printf(“input point1.x:”);
scanf(“%f”,&pt1.x);
printf(“input point1.y:”);
scanf(“%f”,&pt1.y);
printf(“input point2.x:”);
scanf(“%f”,&pt2.x);
printf(“input point2.y:”);
scanf(“%f”,&pt2.y);
dis=sqrt((pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y));
printf(“The distance of the two points is:%f”,dis);
}
定义一结构体变量,用其表示点坐标,并输入两点坐标,求两点之间的距离
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Tags in this post...
Reply on: @reply_date@
@reply_contents@