c++类编程,设计一个学生类

来源:百度知道 编辑:UC知道 时间:2024/09/24 10:32:47
设计一个学生类(cstudent),它具有的私有数据成员是注册号、姓名、数学、外语、计算机课程的成绩。

具有的公有成员函数是:求三门课总成绩的函数sun,求三门课平均成绩的函数average。显示学生数据信息的函数display,设置学生信息的函数setdata。

然后通过主函数从键盘对学生对象的数组(全班学生信息)进行输入。

然后求出每一个学生的总成绩、平均成绩,并显示全班学生总成绩最高的同学的全部数据信息。

private
int num;
string name;
int grade_man,grade_eng,grade_com;
public
int sum(int,int,int)
int avg(int,int,int)

学生成绩管理系统 代码

#include "stdio.h" /*I/O函数*/
#include "stdlib.h" /*其它说明*/
#include "string.h" /*字符串函数*/
#include "conio.h" /*屏幕操作函数*/
#include "mem.h" /*内存操作函数*/
#include "ctype.h" /*字符操作函数*/
#include "alloc.h" /*动态地址分配函数*/
struct score
{
int mingci;
char xuehao[8];
char mingzi[20];
float score[6];
}data,info[1000];
int i,j,k=0;
char temp[20],ch;
FILE *fp,*fp1;

void shuru()
{
if((fp=fopen("s_score.txt","ab+"))==NULL)
{
printf("cannot open this file.\n");
getch();exit(0);
}
for(i=0;i<=1000;i++)
{
printf("\nPlease shuru xuehao:");
gets(data.xueha