stru_03.cpp

来自「数据结构常用算法合集」· C++ 代码 · 共 20 行

CPP
20
字号
//stru_03.cpp
#include <iostream.h>
#include <conio.h>
struct rec
{ int chi,eng,math,total;
  float ave;
}Bill={90,80,87,0,0};				//直接定义变量及字段常数

void main()
{ Bill.total=Bill.chi+Bill.eng+Bill.math;	//计算总分
  Bill.ave=Bill.total/3.0;				//求平均
  cout << "Bill的成绩:";
  cout <<"\n语文="<<Bill.chi;			//输出各字段分数
  cout <<"\n英语="<<Bill.eng;
  cout <<"\n数学="<<Bill.math;
  cout <<"\n总分="<<Bill.total;
  cout <<"\n平均="<<Bill.ave<<"\n";
  getch();
}

⌨️ 快捷键说明

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