天天看點

0309 複利算法

#include<stdio.h>

#include <math.h>

main()

{

double F,P,I;

int M,N;

printf("\t歡迎進入複利計算軟體1.0\n");

printf("請輸入存入本金:");

scanf("%lf",&P);

printf("請輸入年利率:");

scanf("%lf",&I);

printf("請輸入存入年限:");

scanf("%d",&N);

printf("請輸入年複利次數:");

scanf("%d",&M);

printf("本金 年利率 存入年限 年複利次數\n");

printf("%.2lf %.2lf %d %d",P,I,N,M);

I=pow((1+I/M),M)-1;

F=P*pow((1+I),N);

printf("\n輸出複利終值結果:%.2lf\n",F);

}