Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "rectangle.h"
  3. #include "rectangle.h"
  4.  
  5. int main() {
  6. struct Rectangle rect;
  7. scanf("%f %f %f %f", &rect.x1, &rect.y1, &rect.x2, &rect.y2);
  8. printf("%f", perimetr(rect));
  9. printf("%f", area(rect));
  10. return 0;
  11. }
  12. ////
  13. #ifndef LABA11_RECTANGLE_H
  14. #define LABA11_RECTANGLE_H
  15.  
  16. struct Rectangle
  17. {
  18. float x1, y1;
  19. float x2, y2;
  20. };
  21.  
  22. float perimetr(struct Rectangle rect);
  23. float area(struct Rectangle rect);
  24.  
  25. #endif
  26. ///
  27. #include "rectangle.h"
  28.  
  29. float perimetr(struct Rectangle rect)
  30. {
  31. float per = 2 * ((rect.x2 - rect.x1) + (rect.y2 - rect.y1));
  32. return per;
  33. }
  34.  
  35. float area(struct Rectangle rect)
  36. {
  37. float ar = (rect.x2 - rect.x1) * (rect.y2 - rect.y1);
  38. return ar;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement