C++高手进来帮忙 急

2024-12-22 13:42:44
推荐回答(3个)
回答1:

针对你的题写的算法,实现和调试我没写
第一题:
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<<"最高分"<else
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)
{
//冒泡排序
}
};

回答2:

include
using namespace std;
class student2
{
public:
friend class student1;
}
class student1
{
private:
int grade ;
char *name;
};

回答3:

自己做一下也好