造福后人
查看原帖
造福后人
307940
aaaaaaaawsl楼主2023/10/29 01:16

提供一个对拍造小数据的程序,以此纪念我从上午九点开始写到现在才过,对着5K的代码每次都先手摸一遍错误数据,再从头运行程序,一句话一句话的看变量值的变化。

#include<bits/stdc++.h>

using namespace std;

int a[120];
int main(){
	freopen("1.in", "w", stdout);
	srand(time(0));
	int n = rand() % 5 + 5, l = rand() % 4 + n, m = rand() % (l - 3) + 1;
	cout << n << ' ' << m << ' ' << l;
	puts("");
	for(int i = 1, lst = l - 1; i < m; ++ i){
		a[i] = (lst = rand() % (lst - (n - i + 1)) + n - i + 1);
	}
	sort(a + 1, a + m);
	for(int i = 1; i < m; ++ i) cout << a[i] << ' ';
	puts("");
	for(int i = 1; i <= m; ++ i) cout << rand() % 2 + 1 << ' ';  
	puts("");
	for(int i = 1; i <= n; ++ i){
		cout << rand() % 2 << ' ';
		cout << rand() % l;
		puts("");
	}
	return 0;
}
2023/10/29 01:16
加载中...