针对你的题写的算法,实现和调试我没写
第一题:
class student
{
public:
student(string name, float score)
{
this->name = name;
this->score = score;
}
friend void compare(student s1, student s2);
private:
string name;
float score;
};
void compare(student s1, student s2)
{
if(s1.score>s2.socre)
cout<<"最高分"<
cout<<"最高分"<
第二题:
class process;
class sample
{
public:
sample(int n)
{
this->n = n;
A = new int[this->n];
}
~sample()
{
delete[] A;
}
friend class process;
private:
int * A;
int n;
};
class process
{
void chooseSort(sample s)
{
//选择排序
}
void bubbleSort(sample s)
{
//冒泡排序
}
};
include
using namespace std;
class student2
{
public:
friend class student1;
}
class student1
{
private:
int grade ;
char *name;
};
自己做一下也好