C language student basic information input and output

describe

Enter a student's student number and the scores of three subjects (C language, mathematics, and English) in sequence, and output the student's student number and scores of the three subjects on the screen (Note: When outputting the scores, rounding is required and 2 decimal places are retained).

Data range: The student number satisfies 1 \le n \le 20000000 \1≤n≤20000000. The scores of each subject use the percentage system, and there is no possibility of negative numbers.

Enter description:

Student ID and 3 subject scores are separated by English semicolons, and scores are separated by English commas.

Output description:

Student ID, 3 subject scores, please see the output sample for details on the output format.

Example 1

enter:

17140216;80.845,90.55,100.00

Output:

The each subject score of No. 17140216 is 80.85, 90.55, 100.00.

Directly upload the code

#include <stdio.h>

int main() 
{
    int a=0;
    float b=0,c=0,d=0;
    scanf("%d;%f,%f,%f",&a,&b,&c,&d);
    printf("The each subject score of No. %d is %.2lf, %.2lf, %.2lf.",a,b,c,d);
    return 0;
}
    

 

Note that float cannot be written as double, otherwise rounding errors will occur. For example, the final output will be 80.94 instead of 80.95.

And pay attention to the format of the final output 

Guess you like

Origin blog.csdn.net/wangduduniubi/article/details/128537941