Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <math.h>
  4. #define N 4
  5. int i;
  6. typedef struct { int x, y;}punct;
  7. punct p1, p2;
  8. punct pct[N];
  9. punct *pp;
  10.  
  11. void main()
  12. {
  13. citire();
  14. afisare();
  15. distanta(p1.x,p2.x,p1.y,p2.y);
  16. getch();
  17.  
  18.  
  19. }
  20. void citire()
  21. {
  22. printf("Introduceti coordonate pentru p1:");
  23. printf("\np1.x=");
  24. scanf("%d", &p1.x);
  25. printf("p1.y=");
  26. scanf("%d", &p1.y);
  27. printf("Introduceti coordonate pentru p2:");
  28. printf("\np2.x=");
  29. scanf("%d", &p2.x);
  30. printf("p2.y=");
  31. scanf("%d", &p2.y);
  32. printf("Introduceti coordonate pentru cele 10 puncte:\n");
  33.  
  34. }
  35. void afisare()
  36. {
  37. printf("Coordonatele sunt:\n");
  38. for(i=0 ; i<N ; i++)
  39. printf("punctul %d - <%d , %d> \n", i, pct[i].x, pct[i].y);
  40. }
  41. void distanta(int a, int b, int c, int d)
  42. {
  43.  
  44. printf("\nDistanta dintre p1 si p2 este: %.2f\n", sqrt((a - b) * (a - b) + (c - d) * (c - d)));
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement