如题,用的是freopen为什么输出文件是0?
单独运行都没有错??
#include <bits/stdc++.h>
using namespace std;
unsigned long f[10000]={0};
unsigned long w[10000];
unsigned long c[10000];
int main()
{
/*freopen("a.in","r",stdin);
freopen("a.out","w",stdout);*/
unsigned long n,m;
cin>>m>>n;
for(int t=1;t<=n;++t)
cin>>w[t]>>c[t];
for(int t=1;t<=n;++t)
for(int i=w[t];i<=m;++i)
if(f[i-w[t]]+c[t]>=f[i])
f[i]=f[i-w[t]]+c[t];
cout<<f[m];return 0;
}
把fclose删了,直接cout可以