当前位置:网站首页>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;
}后面就套用两点间距离公式就行了。
边栏推荐
- Comic | code review is driving me crazy!
- 2021-04-16数组
- JVM简单入门-02
- MySQL-02.工作中对索引的理解
- What is JSX in the JS tutorial? Why do we need it?
- 开发者,你对云计算可能有些误解
- CVPR大会现场纪念孙剑博士,最佳学生论文授予同济阿里,李飞飞获黄煦涛纪念奖...
- The era of copilot free is over! The official version is 67 yuan / month, and the student party and the defenders of popular open source projects can prostitute for nothing
- 搭建一个点歌QQ机器人,另外还能看美女
- Confessing with Snake games (with source code)
猜你喜欢

SQL create a new field based on the comparison date

Unity技术手册 - 生命周期LifetimebyEmitterSpeed-周期内颜色ColorOverLifetime-速度颜色ColorBySpeed

漫画 | Code Review快把我逼疯了!

Three implementation methods of distributed lock

Musk's 18-year-old son petitioned to change his name to sever the father son relationship

Golang quick start (1)

Nuxt.js spa与ssr的区别

RPC kernel details you must know (worth collecting)!!!

JVM简单入门-01

Developer, you may have some misunderstandings about cloud computing
随机推荐
AI芯片技术-2022年
Unity技术手册 - 生命周期内速度限制(Limit Velocity Over Lifetime)子模块和速度继承(Inherit Velocity)子模块
Install the typescript environment and enable vscode to automatically monitor the compiled TS file as a JS file
How does thymeleaf get the value of the request parameter in the URL?
2021-04-16递归
Lying trough, the most amazing paper artifact!
Pet Feeder Based on stm32
2021-04-16方法重载 传参
Lu Qi invests in quantum computing for the first time
谷贱伤农,薪贱伤码农!
2022高考季征文获奖名单公布
2021-04-16 method overload parameter transfer
XML related interview questions
High performance computing center nvme / nvme of nvme of overview
Liujinhai, architect of zhongang Mining: lithium battery opens up a Xintiandi for fluorine chemical industry
【第23天】给定一个长度为 n 的数组,将元素 X 插入数组指定的位置 | 数组插入操作4
MySQL基础-笔记
SQL教程之SQL 中数据透视表的不同方法
高性能算力中心 — NVMe/NVMe-oF — NVMe-oF Overview
基於STM32設計的寵物投喂器