跳到正文

科技·工程

来个 puzzle

Rainybunny约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年1月15日
收录
2026年1月15日
更新
2026年11月20日
篇幅
约 1 分钟

版本

  1. v1当前
C++
// judge.cpp

#include <cstdio>
#include <random>

typedef u_int32_t u32;

u32 guess(void);

__attribute__ ((__noinline__))
u32 sample() {
    return std::random_device()();
}

int main() {
    u32 x = sample();
    u32 y = guess();
    printf("%u <-> %u\n", x, y);
    return 0;
}

实现 guess.cpp,其中实现了 u32 guess(void) 函数,使得 printf 时两个数总是相同。

编译命令:

Bash
g++ judge.cpp guess.cpp -Werror -O2 -o judge
原文
存档评论2 条抓取于