依次输入一个学生的学号,以及3科(C语言,数学,英语)成绩,在屏幕上输出该学生的学号,3科成绩(注:输出成绩时需进行四舍五入且保留2位小数)。
数据范围:学号满足 ,各科成绩使用百分制,且不可能出现负数
学号以及3科成绩,学号和成绩之间用英文分号隔开,成绩之间用英文逗号隔开。
学号,3科成绩,输出格式详见输出样例。
17140216;80.845,90.55,100.00
The each subject score of No. 17140216 is 80.85, 90.55, 100.00.
123456;93.33,99.99,81.20
The each subject score of No. 123456 is 93.33, 99.99, 81.20.
#include <stdio.h> int main() { int n = 0; float C = 0.0; float M = 0.0; float Y = 0.0; scanf("%d;%f,%f,%f",&n,&C,&M,&Y); printf("The each subject score of No. %d is %.2f, %.2f, %.2f.",n,C,M,Y); return 0; }
#include<stdio.h> int main() { int n=0; float c=0; float math=0; float english=0; scanf("%d;%f,%f,%f",&n,&c,&math,&english); printf("The each subject score of No. %d is %.2f, %.2f, %.2f.",n,c,math,english); return 0; }
#include <stdio.h> #include <math.h> // Function to round a score to two decimal places double round_score(double); int main() { int id; double score1, score2, score3; scanf("%d;%lf,%lf,%lf", &id, &score1, &score2, &score3); score1 = round_score(score1); score2 = round_score(score2); score3 = round_score(score3); printf("The each subject score of No. %d is %.2f, %.2f, %.2f.", id, score1, score2, score3); return 0; } double round_score(double score) { return round(score*100)/100; }