Problem X:c language exercises student scores input and output time limit:1 Sec Memory limit:128 MB
submit:4722 solved:2284
[Submit] [Status] [Web Board] Description
Write a function print that prints an array of students ' scores, with data for 5 students, each of which includes NUM (student number), name (name), Score[3] (3-course score). Write a function input that is used to enter data for 5 students.
Input
5 student's number, name, 3-course Grade
Output
5 student's number, name, 3-course Grade
Sample Input
1001 Zhangsan 861002 Lisi, 801003 Wangwu, 891004 yanping, 1001005 Xiaoxiao 60 60 60
Sample Output
1001 Zhangsan 861002 Lisi, 801003 Wangwu, 891004 yanping, 1001005 Xiaoxiao 60 60 60
HINT
The main function is given below, and it is not required to include the following main function when committing
/* C code */
int main ()
{
const int n=5;
struct student stu[n];
void input (struct student [],int);
void print (struct student [],int);
Input (stu,n);
Print (stu,n);
return 0;
}
/* C + + code */
int main ()
{
const int n=5;
Student Stu[n];
void input (student [],int);
void print (student [],int);
Input (stu,n);
Print (stu,n);
return 0;
}
#include <stdio.h>struct student{ int Xuehao; Char name[20]; int score[3];} Stu;void input (struct student stu[],int n) { int i,j; for (i=0;i<n;i++) { scanf ("%d%s", &stu[i].xuehao,&stu[i].name); for (j=0;j<3;j++) { scanf ("%d", &stu[i].score[j]); } }} void print (struct student stu[],int n) { int i,j; for (i=0;i<n;i++) { printf ("%d%s", stu[i].xuehao,stu[i].name); for (j=0;j<3;j++) { printf ("%d", stu[i].score[j]); } printf ("\ n");} } int main () { const int n=5; struct student stu[n]; void input (struct student [],int); void print (struct student [],int); Input (stu,n); Print (stu,n); return 0;}
Problem X:c language exercises student performance input and output