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

学生基本信息输入输出

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

#include <stdio.h>
#include <math.h>
int main() {
    int number;
    float score1,score2,score3;
    scanf("%d;",&number);
    scanf("%f,%f,%f",&score1,&score2,&score3);
    if(number<1||number>20000000)
    {
        return 0;
    }
    //对成绩进行四舍五入
    double rounded_score1=round(score1);
    double rounded_score2=round(score2);
    double rounded_score3=round(score3);
    printf("The each subject score of No. %d is %.2f, %.2f, %.2f.",number,score1,score2,score3);//%。2f表示小数点后保留两位数
    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
01-10 16:40
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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