请帮我把这段Pascal代码译成C语言代码
发布网友
发布时间:2024-10-06 13:35
我来回答
共1个回答
热心网友
时间:2024-11-04 04:38
//---------------------------------------------------------------------------
#include <stdio.h>
int main(int argc, char* argv[])
{
double f[10001]={0}; /*ANSI C中没有int64内置类型,用double代替*/
long int a[25];
long int i,j,n,v;
FILE *input=fopen("money.in","r"),*output=fopen("money.out","w");
fscanf(input,"%ld%ld",&v,&n);
for (i = 0; i<v; i++) {
fscanf(input,"%ld",&a[i]);
}
getchar();
f[0]=1;
for (i = 0; i<v; i++)
for (j=0; j<n; j++)
if (j>=a[i]) f[j]=f[j]+f[j-a[i]];
printf("%.0lf\n",f[n-1]);
fclose(input);
fclose(output);
return 0;
}
//---------------------------------------------------------------------------