假如2015年房价80万,今年我大学毕业第一年月工资是2000元,我的年工资增长率应该至少是多少,到2015年才能买的起房.
用循坏做呀
我想可以这样吗?
for(i=0;i<=7;i++)
{年工资=年工资*(1+年增长率(求的))
if(年工资<=80万)
{break;}
}
不行该怎么算呀
#include <stdio.h>
#include <math.h>
#define HOUSE_PRICE 800000.0
#define YEARS 2015-2007
/**
Your annual salary increase is 39.14%
Press any key to continue . . .
*/
float rate(float firstYearSalary)
{
float x=0.0;
do
{
x+=0.0001; // increase by 0.01%
}
while( firstYearSalary * (pow(1.0+x, YEARS)-1)/x < HOUSE_PRICE);
return x*100;
}
int main()
{
float firstYearSalary=24000.0;
printf("Your annual salary increase is %.2f%%\n", rate(firstYearSalary));
return 0;
}