我打的代码按输入样例输入和输出样例的结果不一样,不知道哪里错了
求帮助!
应该是(1+rate)的year次方,不是相乘
改为 i = m * pow(1+rate,year) - m
#include <stdio.h>
#include <math.h>
int main(){
double in,mo,ra,ye;
scanf("%lf %lf %lf",&mo,&ye,&ra);
in=mo*pow((1+ra),ye)-mo;
//a的b次方表示为 pow(a,b)
printf("interest = %.2lf",in);
return 0;
}