paste bin
Author
Language
C++
Plain text
Accesslog
Action script
Ada
Apache
Arduino
Armasm
Autohotkey
Awk
Bash
Basic
Brainfuck
C
Clojure
Cmake
C#
css
D
Delphi
Dockerfile
Erlang
Fortran
F#
Gauss
Go
Gradle
Graphql
Groovy
Haskell
Ini
Java
JavaScript
json
Julia
Kotlin
Lasso
LaTeX
Leaf
lisp
llvm
Lua
Makefile
Markdown
Mathematica
Matlab
Nginx
Objective-C
Ocaml
Oxygene
Perl
PgSQL
php
Powershell
Processing
Profile
Properties
Puppet
Purebasic
Python
Q
QML
R
Ruby
Rust
Scala
Scheme
Scilab
Shell
Smalltalk
SQL
Swift
Typescript
VB.NET
VB Script
Verilog
Vim
Wasm
x86asm
Xml
Xquery
Yaml
source code:
#include <cstdio> #include <cmath> #include <algorithm> using std::min; double dist(int x1,int y1,int x2,int y2) { int dx=x2-x1,dy=y2-y1; return dx*dx+dy*dy; } int main(void) { int x,y,x1,x2,y1,y2; double d; scanf("%d%d%d%d%d%d",&x,&y,&x1,&y1,&x2,&y2); if(x1<=x && x<=x2) { d=dist(x,y,x,y1); d=min(d,dist(x,y,x,y2)); } else if(y1<=y && y<=y2) { d=dist(x,y,x1,y); d=min(d,dist(x,y,x2,y)); } else { d=dist(x,y,x1,y2); d=min(d,dist(x,y,x1,y1)); d=min(d,dist(x,y,x2,y1)); d=min(d,dist(x,y,x2,y2)); } printf("%.01lf\n",sqrt(d)); return 0; }
comment: