//StudentManage.h
//VC对标准C++支持不行 你要只有VC 那我就只能给你改成这样的了- -#
//#include
#include
//using namespace std;
class Student
{
private:
char* m_name;//string m_name;
unsigned int m_stuID;
float m_math;
float m_english;
float m_chinese;
float m_cplusplus;
float m_sum;
public:
Student(unsigned int);
~Student();
float GetSum()const{return m_sum;}
friend class Printer;
friend istream& operator>>(istream&,Student&);
friend ostream& operator<<(ostream&,Student&);
};
istream& operator>>(istream& is,Student& stu)
{
cout<<"请输入第"<
cout<<"请输入"<
cout<<"请输入"<
cout<<"请输入"<
cout<<"请输入"<
stu.m_sum=stu.m_math+stu.m_english+stu.m_chinese+stu.m_cplusplus;
return is;
}
ostream& operator<<(ostream& os,Student& stu)
{
os<<"姓名:"<
}
//StudentManage.cpp
#include
#include
#include "StudentManage.h"
using namespace std;
Student::Student(unsigned int ID):m_stuID(ID)
{
m_name=new char[50];
}
Student::~Student()
{
}
class Printer
{
public:
Printer(){count=0;m_SumMath=0;m_SumEn=0;m_SumCN=0;m_SumCP=0;}
void operator()(Student stu);
void Display()
{
cout<<"数学平均成绩:"<
private:
int count;
float m_SumMath;
float m_SumEn;
float m_SumCN;
float m_SumCP;
}printer;
void Printer::operator ()(Student stu)
{
count++;
m_SumMath+=stu.m_math;
m_SumEn+=stu.m_english;
m_SumCN+=stu.m_chinese;
m_SumCP+=stu.m_cplusplus;
}
void main()
{
unsigned int StuNum=0;
cout<<"请输入学生的数量:"<
vector
AllStudent.reserve(StuNum);
for (int i=0;i
Student stu(i+1);
cin>>stu;
AllStudent.push_back(stu);
}
for_each(AllStudent.begin(),AllStudent.end(),printer).Display();
float maxsum=0;
typedef vector
for(StuIte ite=AllStudent.begin();ite!=AllStudent.end();++ite)
{
if (ite->GetSum()>maxsum)
{
maxsum=ite->GetSum();
}
}
cout<
{
if (iter->GetSum()==maxsum)
{
cout<<*iter<
}
}
等价的指针形式。
要这样
template
void sumAll(type (*data)[Cols],type *result)
另外
for (int i=0;i
for (int i=0;i
留下邮箱我发给你吧!
题目不难……但是费事……起码得要个上百分……不然帮你做出来的人肯定就是义务劳动了……
这道题我们也做过的,我发到你邮箱了,你看一下是你想要得不!