URI-1015 Solve

Distance Between Two Points

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read the four values corresponding to the x and y axes of two points in the plane, p1 (x1, y1) and p2 (x2, y2) and calculate the distance between them, showing four decimal places after the comma, according to the formula:
Distance = 

Input

The input file contains two lines of data. The first one contains two double values: x1 y1 and the second one also contains two double values with one digit after the decimal point: x2 y2.

Output

Calculate and print the distance value using the provided formula, with 4 digits after the decimal point.
Input SampleOutput Sample
1.0 7.0
5.0 9.0
4.4721
-2.5 0.4
12.1 7.3
16.1484
2.5 -0.4
-12.2 7.0
16.4575
Problem link: https://www.urionlinejudge.com.br/judge/en/problems/view/1015

Solution:

  • [tab]
    • C
      • #include <stdio.h>
        #include <math.h>
        
        int main()
        {
         double x1, x2, y1, y2, dist;
        
         scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
        
         dist = sqrt(pow(x2-x1,2)+pow(y2-y1,2));
        
         printf("%.4lf\n", dist);
         return 0;
        }
    • C++
      • #include <stdio.h>
        #include <math.h>
        
        int main()
        {
         double x1, x2, y1, y2, dist;
        
         scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
        
         dist = sqrt(pow(x2-x1,2)+pow(y2-y1,2));
        
         printf("%.4lf\n", dist);
         return 0;
        }
        
3/Technology/post-list
Name

Codeforces,53,Problem Solve,90,Programming Tricks,1,URI,37,
ltr
item
DorHubs: URI-1015 Solve
URI-1015 Solve
https://resources.urionlinejudge.com.br/gallery/images/problems/UOJ_1015.png
DorHubs
https://dorhubs.blogspot.com/2019/08/uri-1015-solve.html
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/2019/08/uri-1015-solve.html
true
9087637800571592252
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy