<swustoj>?id=160 C++测试一

链接http://acm.swust.edu.cn/problem/160/

#include <stdio.h>
int main()
{
    double x,dis1,dis2,dis3,dis4,dis5,y;
    dis1=1;
    dis2=0.95;
    dis3=0.9;
    dis4=0.85;
    dis5=0.8;
    while(scanf("%lf",&x)!=EOF)
    {
        if(x>=0&&x<1000)
        {
            y=x;
            printf("discount=%g,pay=%g\n",dis1,y);
        }
        if(x>=1000&&x<=2000)
        {
            y=x*0.95;
            printf("discount=%g,pay=%g\n",dis2,y);
        }
        if(x>=2000&&x<3000)
        {
            y=x*0.9;
            printf("discount=%g,pay=%g\n",dis3,y);
        }
        if(x>=3000&&x<5000)
        {
            y=x*0.85;
            printf("discount=%g,pay=%g\n",dis4,y);
        }
        if(x>=5000)
        {
            y=x*0.8;
            printf("discount=%g,pay=%g\n",dis5,y);
        }
    }
    return 0;
}

 

posted @ 2016-07-30 11:46  艹kiss灬不离  阅读(237)  评论(0)    收藏  举报