题解 | #学生基本信息输入输出#

学生基本信息输入输出

https://www.nowcoder.com/practice/58b6a69b4bf943b49d2cd3c15770b9fd

#include <stdio.h>

int main() 
{
    long num;
    double a,b,c;
    scanf("%ld;%lf,%lf,%lf",&num,&a,&b,&c);
    //四舍五入公式(保留n位小数):x = (int)(x*10^n + 0.5)/10^n.0
    a = (int)(a*100+0.5)/100.0;
    b = (int)(b*100+0.5)/100.0;
    c = (int)(c*100+0.5)/100.0;
    printf("The each subject score of No. %ld is %.2lf, %.2lf, %.2lf.\n", num,a,b,c);
    return 0;
}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务