c语言转换为pascal源程序,求1PASCAL语言转C语言的转换器
#include using namespace std;const int L=1001;int i,j,k,n,m,p,pastmax,nowmax;int coin[L][L],f[L][L],step[L][L];int cost[L],past[L];int main(void){freopen("game.in","r",stdin);freopen("game.out","w",st
#include
using namespace std;
const int L=1001;
int i,j,k,n,m,p,pastmax,nowmax;
int coin[L][L],f[L][L],step[L][L];
int cost[L],past[L];
int main(void)
{
freopen("game.in","r",stdin);
freopen("game.out","w",stdout);
memset(step,2147483647,sizeof(step));//本人推荐不用memset
cin>>n>>m>>p;
for(i=2;i<=n;i++)past[i]=i-1;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
cin>>coin[j][i];
for(i=1;i<=n;i++)cin>>cost[i];
pastmax=0;
for(i=1;i<=m;i++)
{
nowmax=-171717171;
for(j=1;j<=n;j++)
{
if(step[i-1][past[j]]
{
if(pastmax-cost[past[j]]>f[i-1][past[j]])
{step[i][j]=1;f[i][j]=pastmax-cost[past[j]]+coin[i][past[j]];}
else {step[i][j]=step[i-1][past[j]]+1;f[i][j]=f[i-1][past[j]]+coin[i][past[j]];}
}
else {step[i][j]=1;f[i][j]=pastmax-cost[past[j]]+coin[i][past[j]];}
if(f[i][j]>nowmax)nowmax=f[i][j];
}
pastmax=nowmax;
}
cout<
return 0;
}

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)