题解 | #学生基本信息输入输出#
学生基本信息输入输出
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;
}
