Wuhan University of Science and Technology acm:1006:0 starting point algorithm 25--to find the distance between two points

Source: Internet
Author: User
Tags x2 y2

Problem Description

Enter the coordinates of 2 points in the plane coordinate system to output the distance between them

Input

Enter 4 floating-point numbers x1 y1 x2 y2, respectively (x1,y1) (x2,y2) coordinates (multiple sets of data)

Output

Outputs the distance between them, preserving 2 decimal places (one row per group of data)

Sample Input

1 0 2 0

Sample Output

1.00

1#include <stdio.h>2 3#include <math.h>4 5  6 7 intMain ()8 9 {Ten  One          floatX1,y1,x2,y2; A  -          DoubleLen; -  the           while(SCANF ("%f%f%f%f", &x1,&y1,&x2,&y2)! =EOF) -  -          { -  +Len=sqrt ((x2-x1) * (x2-x1) + (y2-y1) * (y2-y1)); -  +printf"%.2lf\n", Len); A  at          } -  -                    return 0; -  -}

Other code:

1#include <stdio.h>2#include <math.h>3 intMain ()4 {5     DoubleX1,x2,y1,y2;6     Doubledistance;7      while(SCANF ("%LF%LF%LF%LF", &x1,&y1,&x2,&y2)! =EOF)8     {9Distance=sqrt (Fabs (x1-x2) *fabs (x1-x2) +fabs (y1-y2) *fabs (y1-y2));Tenprintf"%.2lf\n", distance); One     } A     return 0; -}

Wuhan University of Science and Technology acm:1006:0 starting point algorithm 25--to find the distance between two points

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.