您的位置:首页 > 编程语言 > C语言/C++

Problem E: C语言习题 学生成绩输入和输出

2017-03-22 14:41 344 查看
问题及代码:

Problem E: C语言习题 学生成绩输入和输出

Time Limit: 1 Sec Memory Limit:
128 MB

Submit: 3651 Solved: 1816

[Submit][Status][Web
Board]

Description

编写一个函数print,打印一个学生的成绩数组,该数组中有5个学生的数据,每个学生的数据包括num(学号)、name(姓名)、score[3](3门课的成绩)。编写一个函数input,用来输入5个学生的数据。

Input

5个学生的学号,姓名,3门课的成绩

Output

5个学生的学号,姓名,3门课的成绩

Sample Input

1001 zhangsan 100 90 86
1002 lisi 90 20 80
1003 wangwu 90 90 89
1004 yanping 100 100 100
1005 xiaoxiao 60 60 60

Sample Output

1001 zhangsan 100 90 86
1002 lisi 90 20 80
1003 wangwu 90 90 89
1004 yanping 100 100 100
1005 xiaoxiao 60 60 60

/*烟台大学计算机学院
作者:景怡乐
完成时间:2017年3月22日
*/
#include <stdio.h>
#include <stdlib.h>
struct student
{
int num;
char name[20];
int score1;
int score2;
int score3;
};
void input(struct student stu[5],int n)
{
int i;
for(i=0;i<n;i++)
scanf("%d %s %d %d %d",&stu[i].num,stu[i].name,&stu[i].score1,&stu[i].score2,&stu[i].score3);
}
void print(struct student stu[5],int n)
{
int i;
for(i=0;i<n;i++)
printf("%d %s %d %d %d\n",stu[i].num,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3);
}
int main()
{
const int n=5;
struct student stu
;
void input(struct student [],int );
void print(struct student [],int );
input(stu,n);
print(stu,n);
return 0;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐