C++编程题目 (请勿使用C语言编程)

2024-11-25 07:47:42
推荐回答(3个)
回答1:

#include
#include
using namespace std;
const int n=10;
struct student
{
char num[6];
char name[8];
int score[4];
}stu[n];
int main()
{
void print(student stu[]);
double average(student &stu);
student max(student stu[]);

int i,j;
for (i=0;i {
cout<<"input scores of student "< cout<<"NO.: ";
cin>>stu[i].num;
cout<<"name: ";
cin>>stu[i].name;
for (j=0;j<3;j++)
{
cout<<"score "< cin>>stu[i].score[j];
}
cout< }
print(stu);

for (i=0;i {
cout<<"stu["< }

student max_=max(stu); //获取最大值平均值的学生

//打印最高分学生数据
cout<<"the max student is: "<<"NO.:"< for (j=0;j<3;j++)
{
cout< }
cout<<" average: "< return 0;
}

void print(student stu[])
{
int i,j;
cout<<" NO. name score1 score2 score3"< for (i=0;i {
cout< for (j=0;j<3;j++)
cout< cout< }
}

double average(student &stu)
{
return (stu.score[0]+stu.score[1]+stu.score[2])/3.0;
}

student max(student stu[])
{
double max=average(stu[0]);
int j=0;
for (int i=1;i if(average(stu[i])>max)
{
max=average(stu[i]);
j=i;
}

return stu[j];
}

按照你的思路编的,望采纳

回答2:

第一题: #include "stdio.h" float *Grade(float *num,int i) //必须使用递归函数,否则扣掉20分。 8、编写函数Squeeze(char s[],char c),EyGGvT

回答3:

为什么用结构体呢,用c++的class类多好啊。