📄 knapsack1.cpp
字号:
// knapsack1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "knapsack1.h"
#include "comm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
//CString strHello;
//strHello.LoadString(IDS_HELLO);
//cout << (LPCTSTR)strHello << endl;
int res[NUMBER];
int w = 0;
int t,sum = 0;
int g = 0;
for(int k=0;k<COUNT;k++)
{
cout << "No: " << k << endl;
init2();
t= DoGA();
w = GetCurWeight();
if(w==6666) sum++;
if(t>g)
{
g = t;
w = GetCurWeight();
GetDom(&res[0]);
}
}
cout << COUNT << "次结果中:" << endl;
cout << "装满袋子的次数 : " << sum << endl;
cout << "取得最多的金块数 : " << g << endl;
cout << "此时的袋子占用 : " << w << endl << "具体取法 : " << endl;
for(k=0;k<NUMBER;k++)
cout << res[k] << " ";
cout << endl;
}
return nRetCode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -