ACM对拍程序-预处理文件

今天一道题卡了很久没找到bug,所以学习了一下对拍,结果成功找到了bug,所以在这里记录一下对拍。

首先三个程序,分别是生成测试数据make.cpp、标程standard.cpp、自己的程序myself.cpp。

make.cpp的数据各种生成方式

范围内的整数:

#include<stdio.h>  
#include<stdlib.h>  
#include<string.h>  
#include<math.h>  
#include<time.h>  
int main( )  
{  
    srand( time( NULL ) );  
    int t = 99,n = 10 ;  
    while( n-- )  
    {  
           printf("%d\n",rand() % t );  
           }  
    return 0;  
}  
其中t为最大值。
小数:
#include<stdio.h>  
#include<stdlib.h>  
#include<string.h>  
#include<math.h>  
#include<time.h>  
int main( )  
{  
    srand( time( NULL ) );  
    int t,n = 10 ;  
    while( n-- )  
    {  
           printf("%.6lf\n",rand()*1.0 / 100 );  
           }  
    return 0;  
}  

字符串:

#include<stdio.h>  
#include<stdlib.h>  
#include<string.h>  
#include<math.h>  
#include<time.h>  
int main( )  
{  
    srand( time( NULL ) );  
    int t = 99,n = 10 ;  
    while( n-- )  
    {  
           printf("%c\n",rand() % 26 + 'A' );  
           }  
    return 0;  
}  

bat的对拍程序写法

写入txt后改后缀为bat,运行即可。无错会一直显示运行下去。ctrl+c可以暂停。

:loop
make.exe > in.txt
standard.exe < in.txt > out1.txt
myself.exe < in.txt > out2.txt
fc /A out1.txt out2.txt
if not errorlevel 1 goto loop
pause
:end   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值