⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c09_05.c

📁 it can help you know C++ souce program quckily
💻 C
字号:
#include <stdio.h>

typedef struct
{
	int		math;		/*数学成绩*/
	int		chinese;	/*语文成绩*/
	int		english;	/*英语成绩*/
} SCORE;

typedef struct
{
	int		No;				/* 学号 */
	char	Name[20];		/* 姓名 */
	SCORE	Score;			/* 三门成绩 */
	int		Average_score;	/* 平均分 */
}Information;

/*函数说明部分*/
void GetInfo( Information *p);		/* 从键盘输入数据 */ 
void Comp( Information *p );		/* 击计算平均分   */ 
int main()
{
	Information Exam;		/* 定义一一个学生信息的结构体变量 */
	GetInfo( &Exam );		/* 输入结构体变量的成员值 ,用地址作为参数 */
	Comp( &Exam );			/* 传引用调用函数的调用过程 ,用地址作为参数 */

	return 0;
}

void GetInfo( Information *p )   /* 形参采用指针类型 */
{
	printf("请输入一位学生的信息:\n");
	printf("学号:");
	scanf("%d",&p->No );
	printf("姓名:");
	scanf("%s",p->Name);
	printf("%s的三门主课成绩(数学,语文,英语)是: \n",p->Name);
	scanf("%d, %d, %d",&(p->Score.math), &(p->Score.chinese), 
						&(p->Score.english) );
}

void Comp( Information *p )	/* 形参采用指针类型 */
{
	p->Average_score = ( p->Score.math + p->Score.chinese + 
p->Score.english )/3;
	printf("\n调用函数Comp()计算%s的平均成绩成绩如下:\n",p->Name);
	printf("学号:%3d\n数学:%3d,语文:%3d,英语:%3d\n", 
p->No,p->Score.math,p->Score.chinese,p->Score.english );
	printf("三门功课平均成绩:%3d\n", p-> Average_score );
	if ((p-> Average_score) >= 85 )
		printf("成绩优秀!\n");
	else
		printf("成绩一般!\n");
}

⌨️ 快捷键说明

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