Advertisement
FelipeNeto2

DISTANCIA

May 16th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int distancia(int x1, int x2, int y1, int y2){
  5.   float d;
  6.  
  7.   d = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
  8.  
  9.   return d;
  10. }
  11.  
  12. int main(void) {
  13.   float x1, x2, y1, y2, d;
  14.  
  15.   printf("Digite o ponto x1: ");
  16.   scanf("%f", &x1);
  17.  
  18.   printf("Digite o ponto y1: ");
  19.   scanf("%f", &y1);
  20.  
  21.   printf("Digite o ponto x2: ");
  22.   scanf("%f", &x2);
  23.  
  24.   printf("Digite o ponto y2: ");
  25.   scanf("%f", &y2);  
  26.  
  27.   d = distancia(x1, x2, y1, y2);
  28.  
  29.   printf("A distância entre os dois pontos é %.2f", d);
  30.  
  31.   return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement