编写一个函数print,打印一个学生的成绩数组,该数组中有5个学生的数据记录,每个记录包括num,name,score[3],用主函数输人这些记录,用print函数输出这些记录

编写一个函数print,打印一个学生的成绩数组,该数组中有5个学生的数据记录,每个记录包括num,name,score[3],用主函数输人这些记录,用print函数输出这些记录

#include <stdio.h>

#define NAMLEN 20
//定义一个student结构体数组,包含5个元素
struct student_t{
	int num;
	char name[NAMLEN];
	int score[3];
} students[5];

void print(struct student_t *stu);

int main(){
	for (int i = 0; i < 5; i++){
		scanf("%d%s%d%d%d", &students[i].num, students[i].name, &students[i].score[0],
			&students[i].score[1], &students[i].score[2]);
	}
	print(students);
	return 0;
}

void print(struct student_t *stu){
	for (int i = 0; i < 5; i++){
		printf("%d %s %d %d %dn", students[i].num, students[i].name, students[i].score[0],
			students[i].score[1], students[i].score[2]);
	}
}

运行截图

 编写一个函数print,打印一个学生的成绩数组,该数组中有5个学生的数据记录,每个记录包括num,name,score[3],用主函数输人这些记录,用print函数输出这些记录

原文链接: https://www.cnblogs.com/cyuyanchengxu/p/13469838.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    编写一个函数print,打印一个学生的成绩数组,该数组中有5个学生的数据记录,每个记录包括num,name,score[3],用主函数输人这些记录,用print函数输出这些记录

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/201319

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月12日 下午8:45
下一篇 2023年2月12日 下午8:45

相关推荐