C语言题目:计算两点间的距离
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离.
输入描述
输入数据由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开
输出描述
对于输入数据,输出一行,结果保留两位小数.
输入样例
0 0 0 1
输出样例
1.00
人气:151 ℃ 时间:2020-05-09 11:39:39
解答
#include
#include
void main()
{
float x1,y1,x2,y2;
float fdist = 0;
scanf("%f%f%f%f",x1,y1,x2,y2);
fdist = sqrtf((x2 - x2) * (x2 - x1) + (y2 - y1) * (y2 - y1));
printf("%.2f",fdist);
}
推荐
猜你喜欢
- 清朝九门提督相当于现在的什么官职?
- Japan is _the east of China.A,to B,on ,in选择?为什么?
- 一个数的小数点先向左移动一位,又向右移动了三位后,所得到的数比原数大495,原来这个数是多少?
- There isn't so much pollution in the coiuntry () in big cities
- The story is ___ interesting that many children enjoy it.
- 补充成语;()()不论
- 我们的生活水平不断改善这句话有什么毛病
- 工地上运到一批水泥,第一次搬了30袋,第二次搬了50袋,还剩下这批水泥的七分之三没搬,这批水泥共有多少袋