Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "rectangle.h"
- #include "rectangle.h"
- int main() {
- struct Rectangle rect;
- scanf("%f %f %f %f", &rect.x1, &rect.y1, &rect.x2, &rect.y2);
- printf("%f", perimetr(rect));
- printf("%f", area(rect));
- return 0;
- }
- ////
- #ifndef LABA11_RECTANGLE_H
- #define LABA11_RECTANGLE_H
- struct Rectangle
- {
- float x1, y1;
- float x2, y2;
- };
- float perimetr(struct Rectangle rect);
- float area(struct Rectangle rect);
- #endif
- ///
- #include "rectangle.h"
- float perimetr(struct Rectangle rect)
- {
- float per = 2 * ((rect.x2 - rect.x1) + (rect.y2 - rect.y1));
- return per;
- }
- float area(struct Rectangle rect)
- {
- float ar = (rect.x2 - rect.x1) * (rect.y2 - rect.y1);
- return ar;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement