60',求助

P1422 小玉家的电费

attempt06 @ 2024-11-10 17:56:47

#include<stdio.h>
main()
{
    int x;
    float y;
    scanf("%d",&x);
    if(x<=150)
      y=x* 0.4463;
    else if(x>150&&x<=400)
      y=(x-150) *0.4663+150*0.4463;
    else
      y=(x-400) *0.5663+(400-151)*0.4663+150*0.4663;
    printf("%.1f",y); 
}

by wzy20110830 @ 2024-11-10 19:03:01

#include <stdio.h>
int main() {
    double x, y;
    scanf("%lf", &x);
    if (x <= 150)
        y = x * 0.4463;
    else if (x > 150 && x <= 400)
        y = (x - 150) * 0.4663 + 66.945;
    else
        y = (x - 400) * 0.5663 + 183.52;
    printf("%.1f", y); 
}

by wzy20110830 @ 2024-11-10 19:03:55

求关


|