T1065-求助大佬,答案匹配但是wa
<!--Markdown-->
1. 1.
#include <stdio.h>
#include <math.h>
void myprintf(double c,double b,double a,double d)//进行打印
{
if(((int)(a*1000))%10 == 0)//判断位数输出rate
if(((int)(a*100))%10 != 0)
printf("%.2f\t\t",a);
else
printf("%.1f\t\t",a);
else
printf("%.3f\t\t",a);
if(((int)(c*100))%10)//判断位数输出月money
printf("%.2f\t\t",c);
else
printf("%.1f\t\t",c);
if(((int)(b*100))%10)//判断位数输出年money
printf("%.2f",b);
else
printf("%.1f",b);
if(a != d)//判断输出换行。最后一行不输出
printf("\n");
}
int main()
{
double money, year,a,b;
scanf("%lf%lf%lf%lf",&money,&year,&a,&b);
const double x = 0.125;
printf("Interest Rate\tMonthly Payment\tTotal Payment\n");//输出标题
for(;a <= b;a+=x)
{
double rate = a/1200;
double s_money = ((int)((money*rate)/(1-1/pow(1+rate,12*year))*100))/100.0;
double year_money = ((int)((money*rate)/(1-1/pow(1+rate,12*year))*100*12*year))/100.0;
myprintf( s_money, year_money, a,b);
}
return 0;
}
Comments: