[COGS] 编写评测插件

由 王者自由 在 2012-04-07 创建  开放分组:全部用户  上次编辑时间:2026-10-02

需要编写spj.cpp文件,目前也支持Lemon,Cena,testlib格式的插件。

编写COGS评测插件,要求spj的返回值(0到100之间整数)表示该测试点得分。

所有判定的执行都是自动的。

例如,对题目BPlusA使用COGS评测插件:

// C风格
#include <stdio.h>

FILE *fin, *fout, *fans, *freport;

int main(int argc, char* argv[]) 
{
    fin = fopen(argv[1],"r");//题目的读入文件
    fout = fopen(argv[2],"r");//选手的输出文件
    fans = fopen(argv[3],"r");//题目的输出文件
    freport = fopen("report.log", "w");
    int n, a, b;
    fscanf(fin, "%d", &n);
    fscanf(fout, "%d%d", &a, &b);
    if(a + b != n)
    {
        fprintf(freport, "std sum is %d, but your sum is %d", n, a + b);
        return 0;
    }
    fclose(fin);    
    fclose(fout);
    fclose(fans);
    return 100;
}
// C++风格
#include <fstream>
using namespace std;

ifstream fin, fout, fans;
ofstream freport;

int main(int argc, char* argv[])
{
    fin.open(argv[1]);//题目的读入文件
    fout.open(argv[2]);//选手的输出文件
    fans.open(argv[3]);//题目的输出文件
    freport.open("report.log");
    int n, a, b;
    fin >> n;
    fout >> a >> b;
    if(a + b != n)
    {
        freport << "std sum is" << "n" << ", but your sum is" << a + b;
        return 0;
    }
    fin.close();
    fout.close();
    fans.close();
    return 100;
}
关于 编写评测插件 的讨论
石页嘉
积分:5
提交:3 / 26
第一

2024-09-12 19:43:44 1楼