一道c语言题目?
展开全部
#include <stdio.h>
#include <math.h>
struct Point
{
double x;
double y;
};
struct Point Input()
{
struct Point p;
scanf("%lf %lf",&p.x,&p.y);
return p;
}
void Output(struct Point p)
{
printf("(%lf,%lf)\n",p.x,p.y);
}
double Distance(struct Point p1, struct Point p2)
{
double x = p1.x - p2.x;
double y = p1.y - p2.y;
double res = sqrt(pow(x,2)+pow(y,2));
return res;
}
int main(void)
{
struct Point p1 = Input();
struct Point p2 = Input();
Output(p1);
Output(p2);
printf("%lf\n",Distance(p1,p2));
}
#include <math.h>
struct Point
{
double x;
double y;
};
struct Point Input()
{
struct Point p;
scanf("%lf %lf",&p.x,&p.y);
return p;
}
void Output(struct Point p)
{
printf("(%lf,%lf)\n",p.x,p.y);
}
double Distance(struct Point p1, struct Point p2)
{
double x = p1.x - p2.x;
double y = p1.y - p2.y;
double res = sqrt(pow(x,2)+pow(y,2));
return res;
}
int main(void)
{
struct Point p1 = Input();
struct Point p2 = Input();
Output(p1);
Output(p2);
printf("%lf\n",Distance(p1,p2));
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询