当前位置:网站首页>NOI OJ 1.3 16:计算线段长度 C语言
NOI OJ 1.3 16:计算线段长度 C语言
2022-06-23 10:12:00 【chd44】
描述
已知线段的两个端点的坐标A(Xa,Ya),B(Xb,Yb),求线段AB的长度。
输入
共两行。
第一行是两个实数Xa,Ya,即A的坐标。
第二行是两个实数Xb,Yb,即B的坐标。
输入中所有实数的绝对值均不超过10000。
输出
一个实数,即线段AB的长度,保留到小数点后3位。
这道题我们需要开根号,所以我们引进了#include<math.h>,这样我们就可以使用sqrt()。
sqrt()表示开根号
#include<stdio.h>
#include<math.h>
int main(){
double a,b,c,d;
scanf("%lf %lf\n",&a,&b);
scanf("%lf %lf",&c,&d);
double e=sqrt((c-a)*(c-a)+(d-b)*(d-b));
printf("%.3lf",e);
return 0;
}后面就套用两点间距离公式就行了。
边栏推荐
- sql根据比较日期新建字段
- Go string comparison
- High performance computing center RDMA implementation technology
- SQL writing problem to calculate the ring ratio of the current month and the previous month
- Golang quick start (2)
- Mysql 的Innodb引擎和Myisam数据结构和区别
- 卧槽,最惊艳的论文神器!
- Bugs encountered in Oracle
- Comic | code review is driving me crazy!
- 高性能算力中心 — NVMe/NVMe-oF — NVMe-oF Overview
猜你喜欢

Personal blog system graduation project opening report

NFTs、Web3和元宇宙对数字营销意味着什么?

Different methods of PivotTable in SQL tutorial

Numerical calculation method

Alimentation des animaux de compagnie basée sur stm32

基於STM32設計的寵物投喂器

laravel8 beanstalk 使用说明

STM32F1与STM32CubeIDE编程实例-红外寻迹传感器驱动

Several practical software sharing

Install the typescript environment and enable vscode to automatically monitor the compiled TS file as a JS file
随机推荐
Unable to enter the system normally, press F8 to select other items to try to enter
同花顺推荐么?手机开户安全么?
thymeleaf中如何给onclick事件传值的方法
Nuxt.js spa与ssr的区别
2021-05-11 static keyword
SQL create a new field based on the comparison date
2021-05-11抽象类
Alimentation des animaux de compagnie basée sur stm32
2021-04-27 classes and objects
Successful experience in postgraduate entrance examination for MTI master of English translation major of Beijing University of science and technology in 2023
After installing these five plug-ins, pycharm can be used for takeoff!
Install the typescript environment and enable vscode to automatically monitor the compiled TS file as a JS file
IPv6 的速度比 IPv4 更快?
在OpenCloudOS使用snap安装.NET 6
High performance computing center RDMA implementation technology
2021-04-16方法重载 传参
regular expression
sql根据比较日期新建字段
2021-05-12 interface definition and Implementation
基於STM32設計的寵物投喂器