用C语言实现画矩形

#include <stdio.h>
// bool数据类型是C99标准新增的, 要使用bool类型需要导入<stdbool.h>头文件
#include <stdbool.h>

typedef struct point {
    int x;
    int y;
} LOPoint;

typedef struct size {
    int width;
    int height;
} LOSize;

typedef struct rect {
    LOPoint origin;
    LOSize size;
} LORect;

LOPoint LOPointMake(int x, int y);
LOPoint LOPointZero();
void printPointInfo(LOPoint pt);

LOSize LOSizeMake(int width, int height);
LOSize LOSizeZero();
void printSizeInfo(LOSize sz);

LORect LORectZero();
LORect LORectMake(int x, int y, int width, int height);
void printRectInfo(LORect rc);

int LORectGetMinX(LORect rect);
int LORectGetMaxX(LORect rect);
int LORectGetMinY(LORect rect);
int LORectGetMaxY(LORect rect);
LOPoint center(LORect rect);

bool LOPointEqualToPoint(LOPoint pt1, LOPoint pt2);
bool LOSizeEqualToSize(LOSize sz1, LOSize sz2);
bool LORectEqualToRect(LORect rect1, LORect rect2);

bool LORectContainsPoint(LORect rect, LOPoint pt);
bool LORectContainsRect(LORect rect1, LORect rect2);

bool LORectIsEmpty(LORect rect);
LORect LORectIntersection(LORect rect1, LORect rect2);
bool LORectIntersectsRect(LORect rect1, LORect rect2);

LORect LORectOffset(LORect rect, int dx, int dy);
LORect LORectInset(LORect rect, int dx, int dy);

void drawRect(LORect rect);
void drawEmptyRect(LORect rect);

函数定义:
#include "rect.h"
#include <stdlib.h>
LOPoint LOP
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值