对拍

对拍还是挺有用的,拍一拍就知道自己又要AC了嘛

1.写一个my.cpp,是有可能正确的,自己也不知道对不对的程序
要写文件输入输出,比如:

1
2
3
4
5
6
7
8
9
10
#include<cstdio>
using namespace std;
int n,ans;
int main()
{
freopen("in.in","r",stdin);
freopen("my.out","w",stdout);
scanf("%d",&n);
printf("%d",n*(n+1)/2);
}

2.再写一个force.cpp,就是暴力了
也要写文件输入输出,比如:

1
2
3
4
5
6
7
8
9
10
11
#include<cstdio>
using namespace std;
int n,ans;
int main()
{
freopen("in.in","r",stdin);
freopen("force.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;i++) ans+=i;
printf("%d",ans);
}

3.还有一个makedata.cpp,造数据

1
2
3
4
5
6
7
8
9
10
11
12
#include<cstdlib>
#include<cstdio>
#include<ctime>
using namespace std;
int x,y;
int main()
{
freopen("in.in","w",stdout);
srand((int)time(0));
x=rand();y=rand();
printf("%d",(x*y)%1000+1);
}

4.建个check.txt,然后改后缀为bat,右键编辑后输入命令

1
2
3
4
5
6
7
@echo off
:loop
makedata
my
force
fc my.out force.out||pause
goto loop

5.点击 check.bat 就会运行对拍,ctrl+c 退出
记得把程序先编译了