hust OJ如何写一个special judge

来源:互联网 发布:淘宝售假保证金 编辑:程序博客网 时间:2024/06/05 06:16

读了一下judge_client,如果是spj, 系统会调用system,传入spj默认路径和三个文件指针参数,执行。

返回0 ,表示AC,非0:WA。

模板代码:

#include <stdio.h>#include <math.h>#define PI acos(-1.0)#define AC 0#define WA 1int main(int argc,char *args[]){    FILE * f_in=fopen(args[1],"r");    FILE * f_out=fopen(args[2],"r");    FILE * f_user=fopen(args[3],"r");    int ret=AC;/**************自己写判题逻辑**************/    double a,b,c,ans1,ans2;    fscanf(f_in,"%lf",&a);    ans2=2.0*PI*a;    ans1=PI*a*a;    fscanf(f_user,"%lf%lf",&b,&c);    if (fabs(ans1-b)<0.0001 && fabs(ans2-c)>0.0001) ret=WA;/************************************/    fclose(f_in);    fclose(f_out);    fclose(f_user);    return ret;}






0 1