这是把前一年的利息作为后一年的本金的代码。
//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
#include "math.h"
int main(void){
double bj,ll;//本金和利率
int n;//年数
printf("Please enter the principal, interest rate and the number of years...\n");
scanf("%lf%lf%d",&bj,&ll,&n);
printf("The total amount is %g\n",bj*pow(1+ll,n));
return 0;
}
float num = 常数 ; //num 表示本金 常数自己写
int n = 0; //n 表示年份
float a = 常数; //a 表示利率 常数自己写
float sum = 0; //sum 表示本息和
sum = num*(1 +n*a ) ;
不清楚,请追问。
答题不宜,望采纳,谢谢!