C++对拍(cmd)和随机数据

C++对拍程序**!不是bat批处理**

#include<bits/stdc++.h>
using namespace std;
double clock(double x)
{
    return x*1000/CLOCKS_PER;
}
int main()
{
    clock_t s,t,t2;
    register int i=1;
    for(;;++i)
    {
        system("data.exe > in.txt");
        s=clock();
        system("std.exe < in.txt  > stdout.txt");
        t=clock();
        system("test.exe < in.txt > testout.txt");
        t2=clock();
        if(system("fc /W stdout.txt testout.txt > nul"))
        {
			printf("point #%d\nWA time used: std %.2lfms test %.2lfms\n",i,clock(t-s),clock(t2-t));
			break;
        }
		printf("point #%d\nAC time used: std %.2lfms test %.2lfms\n",i,clock(t-s),clock(t2-t));
    }
    system("pause>nul");
    return 0;
}
#include<cstdio>
#include<cstdlib>
#include<ctime>
using namespace std;

int main()
{
    for (int i=1;i<=100000;i++)
    {
        system("C:\\random.exe");
        double st=clock();
        system("C:\\sol.exe");
        double ed=clock();
        system("C:\\bf.exe");
        if (system("fc soldata.out bfdata.out")==0) {
           printf("Accepted, 测试点 #%d, 用时 %.0lfms\n",i,ed-st); 
        } else
        {
            printf("Wrong Answer"); 
            return 0; 
        }
    }
    return 0;
}

随机函数

#include<cstdio>
#include<ctime>
using namespace std; 
int main()
{
	srand((unsigned)time(NULL));
	int n=rand();

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值