结构体操作1

C语言结构体

Talk is easy, Show you code!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include "stdio.h"
int main()
{
	struct stu
	{
		char name[16];
		float english, chinese, math;
	};
	struct stu student[3] = {
		{"张三", 80, 90, 60},
		{"李四", 60, 90, 60},
		{"王五", 50, 90, 60}
	};
	int i = 0;
	for (; i < 3; i++)
		printf("%s的平均成绩是%.2f\n", student[i].name,
			   (student[i].english + student[i].chinese + student[i].math) / 3);
	return 0;
}
updatedupdated2020-05-032020-05-03