求助高手帮忙!急需C++源程序设计!!(如果能够运行,会再追加悬赏)

2025-01-07 02:23:57
推荐回答(5个)
回答1:

//StudentManage.h
//VC对标准C++支持不行 你要只有VC 那我就只能给你改成这样的了- -#
//#include
#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<<"请输入第"< is>>stu.m_name;
cout<<"请输入"< is>>stu.m_math;
cout<<"请输入"< is>>stu.m_english;
cout<<"请输入"< is>>stu.m_chinese;
cout<<"请输入"< is>>stu.m_cplusplus;

stu.m_sum=stu.m_math+stu.m_english+stu.m_chinese+stu.m_cplusplus;
return is;
}

ostream& operator<<(ostream& os,Student& stu)
{
os<<"姓名:"< os<<"学号:"< os<<"数学成绩:"< os<<"英语成绩:"< os<<"语文成绩:"< os<<"C++成绩:"< os<<"总成绩:"< return 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<<"数学平均成绩:"< cout<<"英语平均成绩:"< cout<<"语文平均成绩:"< cout<<"C++平均成绩:"< }
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<<"请输入学生的数量:"< cin>>StuNum;

vector AllStudent;
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::iterator StuIte;
for(StuIte ite=AllStudent.begin();ite!=AllStudent.end();++ite)
{
if (ite->GetSum()>maxsum)
{
maxsum=ite->GetSum();
}
}

cout< for(StuIte iter=AllStudent.begin();iter!=AllStudent.end();++iter)
{
if (iter->GetSum()==maxsum)
{
cout<<*iter< }
}

}

回答2:

等价的指针形式。
要这样
template
void sumAll(type (*data)[Cols],type *result)

另外
for (int i=0;i最多的分号是多余的,应该是
for (int i=0;i

回答3:

留下邮箱我发给你吧!

回答4:

题目不难……但是费事……起码得要个上百分……不然帮你做出来的人肯定就是义务劳动了……

回答5:

这道题我们也做过的,我发到你邮箱了,你看一下是你想要得不!