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

学生基本信息输入输出

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

#include <stdio.h>
#include<math.h>

int main() 
{
    long int id = 0;
    double c = 0.0, math = 0.0, english = 0.0;
    scanf("%ld;%lf,%lf,%lf",&id,&c, &math, &english);
    //这里用了round函数进行四舍五入,如果写成类似c+=0.005在某些情况会有误差,具体我也不清楚
    c = round(c*100)/100;
    math = round(math*100)/100;
    english = round(english*100)/100;
    printf("The each subject score of No. %ld is %.2lf, %.2lf, %.2lf.",id,c,math,english);
    return 0;
}

全部评论

相关推荐

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

创作者周榜

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