第三题不会编写,请各位好友帮帮忙

img

回答:代码如下

#include<stdio.h>

int main()
{
    int weight;
    float paymoney;
    static float shouldmoney=0;
    printf("请输入西瓜重量和顾客付钱数目:");
    scanf("%d %f",&weight,&paymoney);
    if(weight>=10){
        shouldmoney+=(weight-10)*0.45;
        weight=10;
    }
    if(weight>=8){
        shouldmoney+=(weight-8)*0.5;
        weight=8;
    }
    if(weight>=6){
        shouldmoney+=(weight-6)*0.55;
        weight=6;
    }
    if(weight<=6){
        shouldmoney+=weight*0.6;
    }
    printf("应付钱数:%f",shouldmoney);
    printf("应找钱数:%f",paymoney-shouldmoney);
}

img