stru_01.cpp

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

CPP
23
字号
//stru_01.cpp
#include <iostream.h>
#include <conio.h>
struct rec
{ int chi,eng,math,total;
  float ave;
};
void main()
{ rec Bill;
  Bill.chi=90;						//直接设置分数;
  Bill.eng=80;
  Bill.math=87;
  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 + -
显示快捷键?