Dev C++的调试与对拍

调试

环境设置

网上说要加DEBUG这些参数类型,可是我电脑不用加也能调试,所以跳过;

操作流程

  1. 按F12编译;
  2. Dev C++的调试与对拍
    点击行号添加断点
  3. Dev C++的调试与对拍
    点击调试;
  4. 程序会在断点处停下,按F8可继续,跳过按钮可直接跳到下一个断点;
  5. 调试的时候可右键添加查看,这样就能看到变量名;
  6. win10下窗口不默认置顶,就比较麻烦,可以去360上面下一个Windows On Top, 简单好用。

对拍

产生随机数的代码

#include<stdlib.h>
#include<iostream>
#include <time.h>
using namespace std;

int main() {
	srand( (unsigned)time( NULL ) );
	unsigned int a, b;
	a = (rand() << 16) + rand();
	b = (rand() << 16) + rand();
	a %= 100000 + 1; //产生[1,100000]的随机数 
	b %= 100000 + 1;
	cout << a << endl << b;
	return 0;
}

批处理文件

:loop
generate.exe > data.txt   
main.exe < data.txt > std.txt  
duipai.exe < data.txt > ans.txt 
fc /A std.txt ans.txt
if not errorlevel 1 goto loop
pause
:end

为了方便使用,全放到同一个文件夹即可。