#include
Int main () { Float r, x, p, y; int i; The scanf (" % f % f % f ", & amp; R, & amp; X, & amp; P); Y=x; for(i=1; i
Y *=(100 + r)/100; Printf (" % 2 f \ n ", y); return 0; } Especially put x to y here, as well as for statement to understand CodePudding user response:
Demand? The code is written out ~ according to demand CodePudding user response:
The reference 1/f, confident boy reply: demand? Code is written according to the demand of ~ According to the annual interest rate r x % deposit, deposit of principal and interest of y=x * p years later (100) (100 + r)/^ p, o y values CodePudding user response:
refer to the second floor weixin_46294972 response: Quote: reference 1/f, confident boy reply: demand? Code is written according to the demand of ~ According to the annual interest rate r x % deposit, deposit of principal and interest of y=x * p years later (100) (100 + r)/^ p, o y Why to define your p into float type? CodePudding user response:
reference 3 building self-confidence boy reply: Quote: refer to the second floor weixin_46294972 response: Quote: 1 reference building self-confidence boy reply: demand? Code is written according to the demand of ~ According to the annual interest rate r x % deposit, deposit of principal and interest of y=x * p years later (100) (100 + r)/^ p, o y Why to define your p into float type? This is the correct answer to online, I just don't understand CodePudding user response:
Save the principal and interest of total=p years later the principal * (1 + apr) ^ p, if the annual interest rate is not the absolute Numbers but percentage will be divided by 100, his code is the cycle for power CodePudding user response:
X on behalf of the principal, r is for interest rates, p represents the number of years, on behalf of p y years later, the total amount of is this meaning? Y=x, said the total amount of the first and principal For loop said cycle in p, each cycle a calculated total amount Y *=(100 + r)/100 is equivalent to y=y * (100 + r)/100, said in a loop, recalculate y, The calculating formula of y=total amount is RMB yuan gold + gold * interest rates, namely, y=y + y * (r/100)=y * (100 + r)/100 The last print y, retain two decimal CodePudding user response:
Deposit capital x, just no interest, so p is the total value is the middle of the x y cycle, cycle represents one year at a time, because I was int type, compared to replace p with the same type, float, is your p (int) p is to put the p forced conversion to type int