根据题意分析:
结构体部分:
学号num 为int类型
姓名name 为char类型
char 称为字符类型,只能用单引号' '
来包围,不能用双引号" "
包围。而字符串只能用双引号" "
包围,不能用单引号' '
包围。输出字符使用 %c,输出字符串使用 %s。
3门课成绩score 为int类型 由于三门课用一维数组score[3]表示
其次input函数、output函数,最后main函数再调用
代码部分:
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
struct student
{
int num;
char name[20];
int score[3];
}stu[5];
void input(struct student stu[])
{
int i, j;
for (i = 0; i < 5; i++)
{
printf("学生%d的num:",i+1);
scanf("%d", &stu[i].num);
printf("学生%d的name:",i+1);
scanf("%s", &stu[i].name);