对拍的代码及用法

代码一

checker.cpp

//对拍之checker
#include<bits/stdc++.h>

using namespace std;

int main()
{
	while(1)
	{
		system("make.exe");
		system("std.exe");
		system("wrong.exe");
		if(system("fc 1.out 2.out"))
		{
			break;
		}
	}
	return 0;
}

代码二

用于造数据

提示我们要注意各个代码中的文件名

//对拍之make
#include<bits/stdc++.h>
#include<ctime>
#include<rand>
#include<stdlib.h>

using namespace std;

int main()
{
    freopen("a+b.in","w",stdout);
    srand(time(0));
    printf("%d %d\n",rand()%10+1,rand()%10+1);
    return 0;
}

 代码三

标准的代码

//对拍之std标准代码,可以用暴力去写
#include<bits/stdc++.h>

using namespace std;

int a,b;

int main()
{
    freopen("a+b.in","r",stdin);
    freopen("1.out","w",stdout);
    cin >> a >> b;
    cout << a + b;
    return 0;
}

 代码四

自己的代码(可能有错的)

//对拍之wrong,可能有错误的代码
#include<bits/stdc++.h>

using namespace std;

int a,b;

int main()
{
    freopen("a+b,in","r",stdin);
    freopen("2.out","w",stdout);
    cin >> a >> b;
    if(a==3)
    {
        a++;
    }
    cout << a + b << endl;
    return 0;
}

 

 

需要注意的

 

 

/*对拍的用法
对拍适用于在考试中我们可以自己搭建一个类似于线上oj
的东西,可以用于比较两组代码在测试数据中的不同
使用顺序
先打开除了checker代码中的所有代码,最后打开checker
由于是死循环,当出现不同的时候会自动停止,如果都相同
那么会一直循环下去,只要长时间的循环我们就可以退出

 

posted @ 2022-02-10 20:41  gcyahzoier  阅读(104)  评论(0)    收藏  举报