Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4.  
  5.  
  6. typedef struct ponto
  7. {
  8.     float x;
  9.     float y;
  10. }Ponto;
  11.  
  12. void imprime(Ponto *p)
  13. {
  14. printf("O ponto fornecido foi: %2f %2f\n", p->x, p->y);
  15. }
  16.  
  17. void ler(Ponto *a)
  18. {
  19.     float x,y;
  20.     printf("Informe x e Y:");
  21.     scanf("%2f %2f", &x, &y);
  22.     a->x = x;
  23.     a-> y = y;
  24. }
  25.  
  26. float distancia(Ponto *a, Ponto *b)
  27. {
  28.     float dist;
  29.     dist = sqrt(((a->x)-(b->x)*(a->x)-(b->x))+ ((a->y)- (b->y)*(a->y)- (b->y)));
  30.     return dist;
  31.  
  32. }
  33.  
  34.  
  35.  
  36. int main()
  37. {
  38.  
  39. Ponto c;
  40. Ponto d;
  41. float di;
  42. ler(&c);
  43. ler(&d);
  44. di = distancia(c,d);
  45. printf("Distancia: %f\n", di);
  46. return 0;
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement