<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;
}
时间: 2024-10-12 08:06:06

<swustoj>?id=160 C++测试一的相关文章

&lt;swustoj&gt;?id=203 Jack&#39;s problem

链接http://acm.swust.edu.cn/problem/203/ #include <stdio.h> int main() { double x1,x2,x3,y1,y2,y3; double s; while(~scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3)) { s=(x1*y2+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2)*1

&lt;swustoj&gt;?id=1157 n个数的最小公倍数

链接http://acm.swust.edu.cn/problem/1157/ #include<stdio.h> int main() { int n,a[12],i,j; while(~scanf("%d",&n)) { for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=a[0];;i++) { for(j=0;j<n;j++) { if(i%a[j]==0) { continue

&lt;swustoj&gt;?id=1158 比成绩

链接http://acm.swust.edu.cn/problem/1158/ #include <stdio.h> int main() { int n; int grade,averagegrade_1,sumgrade_1,averagegrade_2,sumgrade_2,count_1,count_2; int classnum; while(scanf("%d",&n)!=EOF) { count_1=count_2=0; sumgrade_1=sumg

&lt;swustoj&gt;?id=563 String

链接http://acm.swust.edu.cn/problem/563/ #include <stdio.h> #include <string.h> int main() { char str[105]; while(scanf("%s",str)!=EOF) { int leng = strlen(str),i; for(i = 0 ; i< leng ; i ++) { if(str[i]>='a'&&str[i]<=

&lt;swustoj&gt;?id=489 平方和与立方和

链接http://acm.swust.edu.cn/problem/489/ #include <stdio.h> int main() { int m,n; int temp,i,j; int sum_1,sum_2; int a[100005]; while(scanf("%d%d",&m,&n)!=EOF) { if(m>n) { temp=m; m=n; n=temp; } for(i=m;i<=n;i++) { a[i]=i; } su

&lt;swustoj&gt;?id=320 鸡兔同笼

链接http://acm.swust.edu.cn/problem/320/ #include <stdio.h> int main() { int n; scanf("%d",&n); while(n--) { int a; scanf("%d",&a); if(a%2!=0) { printf("0 0\n"); } else { printf("%d %d\n",a/4,a/2); } } r

&lt;swustoj&gt;?id=318 进制变换

链接http://acm.swust.edu.cn/problem/318/ #include <stdio.h> int arr[33]; int main() { int x; int i,j; while(scanf("%d",&x)!=EOF) { int y; y=x; i=j=0; if(x==0) { printf("0\n0\n"); } else { while(x!=0) { arr[i]=x%2; x=x/2; i++; }

&lt;swustoj&gt;?id=278 计分规则

链接http://acm.swust.edu.cn/problem/278/ #include <stdio.h> int main() { int i,n; scanf("%d",&n); int a[105]; for(i=0;i<n;i++) { scanf("%d",&a[i]); } int sum=0,min=a[0],max=a[0]; for(i=0;i<n;i++) { sum=sum+a[i]; if(a[

&lt;swustoj&gt;?id=276 简单的计算器

链接http://acm.swust.edu.cn/problem/276/ #include <stdio.h> int main() { int a,b; char d; while(scanf("%d%c%d",&a,&d,&b)!=EOF) { switch(d) { case '+':printf("%d%c%d=%d\n",a,d,b,a+b);break; case '-':printf("%d%c%d=%