大家帮我看一下下面的程序,C语言的,结果怎么老是为0?求解!!!!!
#include<stdio.h>intf(floatinterestrate,floatmoney,intn){money=money*(1.0+interestrat...
#include<stdio.h>
int f(float interestrate,float money,int n)
{ money=money*(1.0+interestrate);
n--;
if(n>0)
f(interestrate,money,n);
else
return money;
}
int main()
{ float interestrate=0.1;
float money=10000,
int n=10,z;
z=f(interestrate,money,n);
printf("money after ten years is%d\n",z);
return 0;
} 展开
int f(float interestrate,float money,int n)
{ money=money*(1.0+interestrate);
n--;
if(n>0)
f(interestrate,money,n);
else
return money;
}
int main()
{ float interestrate=0.1;
float money=10000,
int n=10,z;
z=f(interestrate,money,n);
printf("money after ten years is%d\n",z);
return 0;
} 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询