6

#include
void dengebenjin(int a,int s,int nx,int ed,float lx)
{
    int b=nx,n=0;
    nx=nx*12;
    float yuegonge,yiguihuanjine=0;
    for(;nx>0;nx--)
{
    if(a>ed)
        printf("输入错误");
        else
    n++;
    yuegonge=(a/b)+(a-yiguihuanjine)*lx;
    yiguihuanjine=n*a/b;
    printf("第%d月还款%f\n",n,yuegonge);
}
}
 void dengebenxi(int a,int s,int nx,int ed,float lx)
{
    int n=0,b=nx;
    nx=nx*12;
    float yuegonge;
    for(;nx>0;nx--)
{
    if(a>ed)
        printf("输入错误");
    else
    n++;
    yuegonge=(a*lx*pow(1+lx,b))/(pow(1+lx,b)-1);
    printf("第%d月还款%f\n",n,yuegonge);
}
}
main()
{
    int zongjia,shoufu,dknx,dked,xuanze;
    float lixi;
    printf("请输入总价.首付.贷款年限.贷款额度.利息:");
    scanf("%d %d %d %d %d",&zongjia,&shoufu,&dknx,&dked,&lixi);

    printf("请选择贷款方式:1.等额本金2.等额本息\n");
    scanf("%d",&xuanze);
if(xuanze==1)
dengebenjin(zongjia,shoufu,dknx,dked,xuanze);
else if(xuanze==2)
dengebenxi(zongjia,shoufu,dknx,dked,xuanze);
}

你可能感兴趣的:(6)