求助对拍相关
  • 板块灌水区
  • 楼主Lyz09G410/G407
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/9/28 15:45
  • 上次更新2023/11/2 17:44:07
查看原帖
求助对拍相关
284013
Lyz09G410/G407楼主2023/9/28 15:45

自己写了个对拍程序,总是因为内存泄漏(应该是)而内存占用过高,然后电脑炸掉,就算关掉所有程序依然内存满占用。

有没有什么解决方案,已经因为这个电脑炸了好几次了。

对拍主程序源码如下:

#include<iostream>
#include<windows.h>
#include<string>
using namespace std;
string dp[100];
string int2str(int w)
{
	string res;
	while(w)
	{
		res=(char)(w%10+'0')+res;
		w/=10;
	}
	return res;
}
int main(int argc,char** argv)
{
	int cnt=1;
	while(1)
	{
		cout<<cnt<<endl;
		system("dm.exe >data.in");
		for(int i=1;i<argc;i++)
		{
			string nm="data"+int2str(i)+".out";
			string cmd=((string)argv[i])+" <data.in "+">"+nm;
			cout<<i<<":"<<cmd<<endl;
			system((char*)(cmd.c_str()));
		}
		for(int i=1;i<argc-1;i++)
		{
			string s1="data"+int2str(i)+".out";
			string s2="data"+int2str(i+1)+".out";
			string cmd="fc "+s1+" "+s2;
			if(system((char*)(cmd.c_str())))
			{
				puts("Error!data:");
				system("type data.in");
				cout<<endl;
				system("pause");
				break;
			}
		}
//		Sleep(1);
		cnt++;
	}
}
2023/9/28 15:45
加载中...