交互库教程
  • 板块学术版
  • 楼主Blikewsr
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/10/21 16:54
  • 上次更新2024/10/21 18:53:09
查看原帖
交互库教程
532992
Blikewsr楼主2024/10/21 16:54

看了 Luogu 的交互库教程,打算尝试以下,然后复制了 Luogu 教程里的 checker.cppinteractive_lib.cpp,然后自己加了一个 1.in1.out.

然后就 RE

  • RE 信息是

Runtime Error.wrong output format Unexpected end of file - int32 expected

Received signal 11: Segmentation fault with invalid memory reference.

  • checker.cpp 代码:
#include "testlib.h"
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
    setName("Interactor A+B");
    registerInteraction(argc, argv);

    int a = inf.readInt();
    int b = inf.readInt();

    cout << a << " " << b << endl;

    int pa = ouf.readInt();
    int ja = a + b;

    if (ja != pa) quitf(_wa, "expected %d, found %d", ja, pa);
    quitf(_ok, "answer is %d", ja);
}
  • interactive_lib.cpp 代码:
#include <iostream>

extern "C" {
    extern int pluss(int a, int b);
}

int main() {
    int a,b;
    std::cin >> a >> b;
    std::cout << pluss(a, b) << std::endl;
    return 0;
}
  • 1.in 内容:
12 23
  • 1.out 内容:(空文件)

  • std.cpp

extern "C" int pluss(int a, int b) {
    return a + b;
}
2024/10/21 16:54
加载中...