C + + brush question--1924: Calculate the distance between two points

Source: Internet
Author: User
1924: Calculate the distance between two points
Description
Enter two point coordinates (X1,Y1), (X2,y2), and calculate and output the distance between two points.
Input
The input data has more than one group, each group occupies a row, consisting of 4 real numbers, representing X1,y1,x2,y2, separated by a space between the data.
Output

For each set of input data, the output is one line and the result retains two decimal places.

/* Copyright (c) 2014, Yantai University School of Computer * All rights reserved. * File name: Test.cpp * Chen Dani * Completion date: May 20, 2015 * Version number: v1.0 * * #include <iostream> #include <iomanip> #include <c Math>using namespace Std;int Main () {    int a,b,c,d;    double S;    while (cin>>a>>b>>c>>d)    {        s=sqrt ((a-c) * (a-c) + (b-d) * (b-d));        Cout<<setiosflags (ios::fixed) <<setprecision (2) <<s<<endl;    }    return 0;}

Experience: By doing problems can increase self-confidence, but also to improve their skills, refueling!!

C + + brush question--1924: Calculate 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.