如何打开洛谷?

· · 闲话

如何打开洛谷? ::::warning[windows端]{open} 前面的区域以后再来探索吧! :::: ::::info[linux端]

#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[] = {
        {"problem", 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;
}
sudo cp aaa /usr/local/bin/luogu
# aaa替换成可执行文件名

:::: ::::success[最终效果]{open}

luogu # 打开洛谷主站
luogu -p P1001 # 打开P1001 A+B Problem

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