用VisualC++6.0设计一个学生成绩管理系统

用VisualC++6.0设计一个学生成绩管理系统

1,信息录入,包括学生学号(10位数),姓名,性别,3门课程的成绩
2,信息查询,可以按照姓名或学号查询学生各门课程的成绩,并显示
3,排序,按平均成绩或各门课程成绩按由高到低进行排序,并显示
4,信息删除与修改,输入学号,可删除或修改该学生的成绩信息

要求:1,利用结构体数组实现学生信息的数据结构设计
2,系统的各个功能模块要求用函数的形式实现
3,程序要有必要注释
敬请编程高手帮忙,2天内搞定!!!

第1个回答  推荐于2021-01-25
// student.h: interface for the student class.
//
//////////////////////////////////////////////////////////////////////

#include "score.h"

//////////////////////////////////////////////////////////////////////
#if !defined(AFX_STUDENT_H__7F838617_8CEB_4640_8740_EA0EFCE6BADE__INCLUDED_)
#define AFX_STUDENT_H__7F838617_8CEB_4640_8740_EA0EFCE6BADE__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class student
{
public:
student();
virtual ~student();
int getNum();
float sum();
void print();
void modify(char* r,char* n,float m,float e,float c);
private:
char number[20];
char name[30];
score ascore;
};

#endif // !defined(AFX_STUDENT_H__7F838617_8CEB_4640_8740_EA0EFCE6BADE__INCLUDED_)

// student.cpp: implementation of the student class.
//
//////////////////////////////////////////////////////////////////////

#include <iostream>
#include <string>
#include <iomanip>
#include "student.h"
using namespace std;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

student::student()
{

}

student::~student()
{

}

void student::print()
{
cout<<setw(8)<<number<<setw(8)<<name;
ascore.print();
}
void student::modify(char* r,char* n,float m,float e,float c)
{
strcpy(number,r);
strcpy(name,n);
ascore.modify(m,e,c);
}

float student::sum()
{
float a;// score.h: interface for the score class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SCORE_H__52859404_C529_4188_9FCD_161B7F88FEB3__INCLUDED_)
#define AFX_SCORE_H__52859404_C529_4188_9FCD_161B7F88FEB3__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class score
{
public:
score(float c=0.0,float m=0.0,float e=0.0);
virtual ~score();
float sum();
void print();
void modify(float m,float e,float c);
private:
float computer;
float english;
float mathematics;
static float total;
};

#endif // !defined(AFX_SCORE_H__52859404_C529_4188_9FCD_161B7F88FEB3__INCLUDED_)
// score.cpp: implementation of the score class.
//
//////////////////////////////////////////////////////////////////////

#include <iostream>
#include <iomanip>
#include "score.h"
using namespace std;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

score::score(float c,float m,float e)
{
computer = c;
mathematics = m;
english = e;
total = computer + english +mathematics;
}

score::~score()
{

}

float score::total = 0;

float score::sum()
{
total = mathematics+english+computer;
return total;
}

void score::print()
{
cout<<setw(8)<<computer<<setw(8)<<english<<setw(8)<<mathematics;
}

void score::modify(float m,float e,float c)
{
mathematics = m;
english = e;
computer = c;
}

#include <iostream>
#include <iomanip>
#include "score.h"
#include "student.h"
using namespace std;

const int maxSize = 50;

int main()
{
student stu[maxSize];
char number[20];
char name[30];
float tmp_sum;
float math,eng,comp;
int total;

do
{
cout<<"please input the number of students: ";
cin>>total;
if (total>maxSize || total<1)
cout<<"ERROR: 0<TOTAL<="<<maxSize<<"(The maxSize)!"<<endl;
}
while (total<1 || total>maxSize);

cout<<"please input the student's message:(number name mathematics english computer)"<<endl;
for (int i=0; i<total; i++)
{
cout<<"学生"<<i+1<<": ";
cin>>number>>name>>math>>eng>>comp;
stu[i].modify(number,name,math,eng,comp);
}

cout<<"***************************************************"<<endl;
cout<<setw(8)<<"学号"<<setw(8)<<"姓名"<<setw(8)<<"计算机"
<<setw(8)<<"英语"<<setw(8)<<"数学"<<setw(8)<<"总 分"<<endl;
for (i=0; i<total; i++)
{ tmp_sum = stu[i].sum();
stu[i].print();
cout<<setw(8)<<tmp_sum<<endl;
}
cout<<"***************************************************"<<endl;
return 0;
}

/* cin>>reg_num;
bool found = false;
for (i=0; i<total; i++)
{
if(stu[i].getNum() == *reg_num)
{
cout<<setw(8)<<"学号"<<setw(8)<<"姓名"<<setw(8)<<"计算机"
<<setw(8)<<"英语"<<setw(8)<<"数学"<<setw(8)<<"总分"<<endl;
stu[i].print();
cout<<setw(8)<<stu[i].sum()<<endl;
found = true;
break;
}
if (!found)
cout<<"没这个人!"<<endl;
}
*/

a = ascore.sum();
return a;

}

参考资料:http://zhidao.baidu.com/question/16755942.html

本回答被网友采纳