C语言代码第三天

题目:

 

代码:

#include<stdio.h>
#include<math.h>
int main()
{
    int tip_percent, tax_percent, total;
    double mealcost, tip, tax;
    scanf("%lf", &mealcost);
    scanf("%d", &tip_percent);
    scanf("%d", &tax_percent);
    tip = mealcost * (double)tip_percent / 100;
    tax = mealcost * (double)tax_percent / 100;
    total = (int)round(mealcost + tip + tax);
    printf("%d", total);
    return 0;
}
关键round函数。(请查看上一篇文章)

 

posted @ 2020-09-10 14:20  谁说的爱  阅读(138)  评论(0)    收藏  举报