跳到正文

闲话

如何打开洛谷?

ca0007665约 2 分钟
原文

这是 2026年2月8日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年2月8日
收录
2026年2月8日
更新
2026年11月7日
篇幅
约 2 分钟

版本

  1. v2当前
  2. v1

如何打开洛谷?

windows端

前面的区域以后再来探索吧!

linux端
C++
#include <iostream>
#include <cstring>
#include <unistd.h>
#include <getopt.h>
int main(int argc, char *argv[]) {
    const char* optstring = "p:";
    char str[200] = "xdg-open https://www.luogu.com.cn/";
    struct option long_opts[] = {
        {"input", required_argument, nullptr, 'p'},
        {nullptr, 0, nullptr, 0}
    };
    int opt;
    while ((opt = getopt_long(argc, argv, optstring, long_opts, nullptr)) != -1) {
        switch (opt) {
            case 'p':
                strcat(str, "problem/");
                strcat(str, argv[2]);
                strcat(str, "/");
                break;
            default:
                std::cerr << "Invalid option" << std::endl;
                return 1;
        }
    }
    system(str);
    std::clog << "ok: open" << str+8 << std::endl;
    return 0;
}
Bash
sudo cp aaa /usr/local/bin/luogu
aaa替换成可执行文件名
最终效果
Bash
luogu # 打开洛谷主站
luogu -p P1001 # 打开P1001 A+B Problem

(该内容疑似AI生成,请仔细甄别)