9-4.c

来自「51单片机开发与应用技术详解(珍藏版)PPT及源码」· C语言 代码 · 共 31 行

C
31
字号
#include <stdio.h>						//头文件

struct kemu							//定义结构kemu
{
float Chinese;							//语文成绩
float English;							//英语成绩
float Math;							//数学成绩
};
struct student							//定义结构student
{
char *name;							//姓名
int 	num;								//学号
int 	age;								//年龄
char *sex;								//性别
struct kemu score;						//成绩
};

void main()							//主函数
{
struct student Bob;						//声明结构变量
Bob.name="Bob ";						//对每个成员进行赋值
Bob.num=210;
Bob.age=22;
Bob.sex="M";
Bob.score.Chinese=90.5;
Bob.score.English=87.5;
Bob.score.Math=96.0;
printf("%s %d %d %s %f %f %f \n",			//输出变量的成员值
Bob.name, Bob.num, Bob.age, Bob.sex, Bob.score.Chinese, Bob.score.English, Bob.score.Math);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?