Known bank deposit rate is r = 2.25%, the deposit principal input x, the number of deposits in n, the output of principal and interest and y = x (1 + r) (1 + r) ... (1 + r), a total of n a (1 + r).

 

/*
Known bank deposit rate is r = 2.25%, the deposit principal input x, the number of deposits in n, the output of principal and interest and y = x (1 + r) (1 + r) ... (1 + r), a total of n a (1 + r).
*/
#include <stdio.h>
#include <string.h>
#include<math.h>
int main()
{
    double r;
    r=0.0225;
    int x,n;
    double y=1.0;
    scanf("%d%d",&x,&n);
    y=x;
    while(n){
        y*=(1+r);
        n--;
    }
    printf("%0.2lf\n",y);
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/zhaohuan1996/p/11976099.html