c语言计算距离问题Problem Description输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距
来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/06/24 13:43:59
c语言计算距离问题
Problem Description
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离.
Input
输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开.
Output
对于每组输入数据,输出一行,结果保留两位小数.
Sample Input
0 0 0 10 1 1 0
Sample Output
1.001.41
我自己写的代码
#include
#include"math.h"
int main()
{
int a,b,c,d;
float z;
while(scanf(" %d%d%d%d",&a,&b,&c,&d)!=EOF)
{
z=(c-a)*(c-a)+(d-b)*(d-b);
printf("%.2f\n",sqrt(z));
}
return 0;
}
提交时显示Output Limit Exceeded
Problem Description
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离.
Input
输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开.
Output
对于每组输入数据,输出一行,结果保留两位小数.
Sample Input
0 0 0 10 1 1 0
Sample Output
1.001.41
我自己写的代码
#include
#include"math.h"
int main()
{
int a,b,c,d;
float z;
while(scanf(" %d%d%d%d",&a,&b,&c,&d)!=EOF)
{
z=(c-a)*(c-a)+(d-b)*(d-b);
printf("%.2f\n",sqrt(z));
}
return 0;
}
提交时显示Output Limit Exceeded
/*1 4 8 08.061 2 3 42.83qPress any key to continue*/#include <stdio.h>
#include <math.h>
int main() {
int a,b,c,d;
double z;
while(scanf("%d%d%d%d",&a,&b,&c,&d) == 4) {
z=(c-a)*(c-a)+(d-b)*(d-b);
printf("%.2lf\n",sqrt(z));
}
return 0;
}
#include <math.h>
int main() {
int a,b,c,d;
double z;
while(scanf("%d%d%d%d",&a,&b,&c,&d) == 4) {
z=(c-a)*(c-a)+(d-b)*(d-b);
printf("%.2lf\n",sqrt(z));
}
return 0;
}
c语言计算距离问题Problem Description输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距
计算两点间的距离Problem Description输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离.
用java语言编写输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离.
/*【问题描述】要求定义和调用函数dist(x1,y1,x2,y2)计算两点 间的距离。
设两点坐标为(x1,y1)(x2,y2) 则两点间的距离公式 d=√[(x1-x2)^2+(y1-y2)^2],这是怎么
阅读下列一段文字,然后回答下列问题.已知在平面内两点P1(x1,y1)、P2(x2,y2),其两点间的距离P1P2
输入4个浮点数x1,y1,x2,y2,输出平面坐标系中点(x1,y1)和(x2,y2)的距离,保留4位小数.
在平面直角坐标系中,以任意两点P( x1,y1)、Q(x2,y2)为端点的线段中点坐标为(x1+x2)/2,(y1+y2
在平面直角坐标系中,以任意两点p(x1,y1)、Q(x2,y2)为端点的线段中点坐标为(x1+x2)/2,(y1+y2)
三维坐标变换问题三维坐标上有两点,A(x1,y1,z1),B(x2,y2,z2) 现在新的坐标系,经过变换,A 点变成了
在平面直角坐标系xOy中,O为坐标原点.定义P(x1,y1)、Q(x2,y2)两点之间的“直角距离”