Skip to content

Latest commit

 

History

History
37 lines (33 loc) · 611 Bytes

71.md

File metadata and controls

37 lines (33 loc) · 611 Bytes

题目:编写input()和output()函数输入,输出5个学生的数据记录。

#include <stdio.h>

struct stu
{
	char name[20];
	char sex[3];
	int age;
};

void input(stu *group)
{
	printf("请输入学生姓名、性别、年龄:\n");
	for (int i = 0; i < 5; ++i)
	{
		scanf("%s%s%d", &group[i].name, &group[i].sex, &group[i].age);
	}
}

void output(stu *group)
{
	printf("打印学生姓名、性别、年龄:\n");
	for (int i = 0; i < 5; ++i)
	{
		printf("%s %s %d\n", group[i].name, group[i].sex, group[i].age);
	}
}

int main()
{
	stu group[5];
	input(group);
	output(group);
	return 0;
}