第四章-4.18
来源:互联网 发布:旋转门plc编程 编辑:程序博客网 时间:2024/05/26 20:24
# include <iostream>
#include<string>
using namespace std;
class student
{
public:
student(string name1,int num1,double score1);
void show();
friend void max(student* p);
private:
string name;
int num;
double score;
};
student::student(string name1,int num1,double score1)
{
name=name1;
num=num1;
score=score1;
}
void student::show()
{
cout<<"name:"<<" "<<name<<endl;
cout<<"num:"<<" "<<num<<endl;
cout<<"score:"<<" "<<score<<endl;
}
void max(student* p)
{
int i,j;
int max=p[0].score;
for(i=0;i<6;i++)
if(max<p[i].score)
{
max=p[i].score;
j=i;
}
cout<<"分数最高是:"<<p[j].name<<endl;
cout<<"学号:"<<p[j].num<<endl;
cout<<"成绩:"<<p[j].score<<endl;
}
int main()
{
student date[6]={
student("a同学",1,90),
student("b同学",2,91),
student("c同学",3,92),
student("d同学",4,93),
student("e同学",5,94),
student("f同学",6,95)
};
student* p;
p=date;
max(p);
return 0;
}
#include<string>
using namespace std;
class student
{
public:
student(string name1,int num1,double score1);
void show();
friend void max(student* p);
private:
string name;
int num;
double score;
};
student::student(string name1,int num1,double score1)
{
name=name1;
num=num1;
score=score1;
}
void student::show()
{
cout<<"name:"<<" "<<name<<endl;
cout<<"num:"<<" "<<num<<endl;
cout<<"score:"<<" "<<score<<endl;
}
void max(student* p)
{
int i,j;
int max=p[0].score;
for(i=0;i<6;i++)
if(max<p[i].score)
{
max=p[i].score;
j=i;
}
cout<<"分数最高是:"<<p[j].name<<endl;
cout<<"学号:"<<p[j].num<<endl;
cout<<"成绩:"<<p[j].score<<endl;
}
int main()
{
student date[6]={
student("a同学",1,90),
student("b同学",2,91),
student("c同学",3,92),
student("d同学",4,93),
student("e同学",5,94),
student("f同学",6,95)
};
student* p;
p=date;
max(p);
return 0;
}
0 0
- 第四章-4.18
- 第四章作业4.18
- 第四章第四题
- 第四章第四题
- 第四章
- 第四章
- 第四章
- 第四章
- 第四章
- 第四章
- 第四章
- 第四章
- 第四章
- 第四章
- 第四章
- 第四章
- 第四章
- 第四章
- 浅谈oauth
- ibatis的resultMap
- Django1.6和1.7静态文件配置方法
- P121 3
- 第三章:输入一个数判断是否为周期数并输出周期及周期个数
- 第四章-4.18
- 电子元器件选型
- 拷贝构造函数和赋值函数的必要性和意义
- 判断字符串是否为数字
- 链表出错记录
- 网页乱版怎么办?添加clear属性禁止浮动
- Android JNI(实现自己的JNI_OnLoad函数)
- C++中的C++关键字浅析
- Java 内存管理与垃圾回收