关于极值

单变量赋值

INF = 0x7fffffff

32 bit signed int 的最大值,即 $2^{32} - 1 = 2147483647 \approx{2.147 \times 10^{9}}$

LLINF = 0x7fffffffffffffff (15个f)

64 bit signed int 的最大值,即 $2^{64} - 1 = 9223372036854775807 \approx{9.223 \times 10^{18}}$

memset()

memset() 的运作方式为按字节设定,如在c++中,一个 int 变量的大小是 4 个字节,则

int var;
memset(var, 0xab, sizeof(var));

此时 var == 0xabababab

而在数组中则是将数组的每一个元素的每一个字节设定,与上面同理。

常用设定

memset(a, 0x3f, sizeof(a))

相当于 for(int i = 0; i < lim; ++i) a[i] = 0x3f3f3f3f;

memset(a, 0x7f, sizeof(a))

相当于 for(int i = 0; i < lim; ++i) a[i] = 0x7f7f7f7f;

memset(a, 0xff, sizeof(a))

相当于 memset(a, -1, sizeof(a))for(int i = 0; i < lim; ++i) a[i] = -1;

memset(a, 0, sizeof(a))

显然。

点赞
  1. Karri Canning说道:
    Google Chrome Windows XP

    DOMAIN SERVICES EXPIRATION NOTICE FOR intoyour.space

    Domain Notice Expiry ON: Jan 21, 2021

    We have actually not obtained a payment from you.
    We have actually tried to email you but were unable to contact you.

    Go To: https://bit.ly/3p9eHB6

    For information and also to process a discretionary payment for your domain website services.

    012120211757093753688578798intoyour.space

发表评论

电子邮件地址不会被公开。必填项已用 * 标注