1 条题解

  • 0
    @ 2025-4-7 21:29:58

    C :

    #include<stdio.h>
    int main(){
      double x, rate, pay;
      scanf("%lfd", &x);
      if(x < 300){
        rate = 1.0;
      } else if(x < 500){
        rate = 0.9;
      } else if(x < 800){
        rate = 0.7;
      } else {
        rate = 0.5;
      }
      pay = x * rate;
      printf("%.2lf %.2lf", rate, pay);
      return 0;
    }
    

    C++ :

    #include<stdio.h>   
    int main()
    { 
    	double x,y;
    	scanf("%lf",&x);
    if (x < 300.00)
    {
        y = x;
    	printf("0.00 %.2lf",y);
    }
    else if (x < 500.00)
    {
        y = 0.90 * x;
        printf("0.90 %.2lf",y);
    }
    else if (x < 800.00)
    {
        y = 0.70 * x;
        printf("0.70 %.2lf",y);
    }
    else 
    {
    	y = 0.50 * x;
        printf("0.50 %.2lf",y);
    }
    	return 0;
    }
    

    Pascal :

    program ex_1;
    var
     a:real;
    begin
     readln(a);
     if a<300 then writeln('0.00 ',a)
     else if (a>=300) and (a<500) then writeln('0.90 ',a*0.9:0:2)
     else if (a>=500) and (a<800) then writeln('0.70 ',a*0.7:0:2)
     else writeln('0.50 ',a*0.5:0:2);
    end.
    
    
    
    
    • 1

    信息

    ID
    1690
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者