• 对拍检验程序


    【程序描述】

    利用C++随机函数编写了数据生成程序,用于代码正确性的检验,从而显著提高AC几率。

    【操作描述】

    (1)编写一个保证答案正确的暴力程序(True.cpp/c/pas);

    (2)编写一个具有不确定性的解题程序(Code.cpp/c/pas);

    (3)编写一个生成合法数据的输出程序(Make.cpp/c/pas);

    源代码:
    
    #include<cstdio>
    #include<ctime>
    #include<algorithm>
    #define INF (?) 
    using namespace std;
    int main()
    {
        freopen("(?).in","w",stdout);
        srand((?)time(NULL));
        for (int a=0;a<(?);a++)
          rand()%INF; //视情况而定。
        fclose(stdout);
        return 0;
    }

    (4)编写一个用于检验的批处理文件(Check.bat),对以上两个程序的输出结果(True.out、Code.out)进行比较检验。

    源代码:
    
    @echo off
    :loop
    Make.exe
    echo %time%>>Time1.txt //检验时间。
    True.exe
    echo %time%>>Time2.txt
    Code.exe
    fc True.txt Code.txt //DOS语言不支持io输入输出流。
    if not errorlevel 1 goto loop
    pause
    goto loop

    【结果描述】

    能够从程序运行结果中看出解题程序是否存在错误,以及出错时正在处理的测试数据。

  • 相关阅读:
    Linux下定时删除指定目下n天前的文件
    日期时间格式化
    sed与awk
    Linux守护进程(init.d和xinetd)
    python-Json模块
    python3 urllib模块
    linux 命令 rsync
    Linux下scp的用法
    代码块重定向
    使用exec
  • 原文地址:https://www.cnblogs.com/Ackermann/p/5986757.html
Copyright © 2020-2023  润新知