第3章 第5题
来源:互联网 发布:北京炸酱面知乎 编辑:程序博客网 时间:2024/04/29 23:28
#include<iostream>#include<iomanip>using namespace std;class Student{private:int num;//student numberdouble score;//scorepublic:friend istream& operator >>(istream& input,Student& s);friend ostream& operator <<(ostream& output, Student& s);friend void max(Student*,int);};istream& operator >>(istream& input,Student& s){cout<<"num:";input>>s.num;cout<<"score:";input>>s.score;return input;}ostream& operator <<(ostream& output, Student& s){output<<setw(8)<<s.num<<setw(8)<<setiosflags(ios::fixed)<<setprecision(1)<<s.score;return output;}void max(Student *stu,int n){Student *p,*max;for(max=stu,p=stu+1;p<stu+n;p++)if(p->score > max->score)max=p;cout<<"The student who has the highest score is:"<<endl;cout<<*max<<endl;}int main(){Student stu[5];for(int cnt=0;cnt<5;cnt++)cin>>stu[cnt];max(stu,5);return 0;}
0 0
- 第3章 第5题
- 第5章 第3题
- 第5章第3题
- 第3章 第3题
- 第2章第5题
- 第2章 第5题
- 第4章 第5题
- 第5章 第1题
- 第5章 第2题
- 第5章第1题
- 第5章第2题
- 第5章 第9题
- 第5章 第10题
- 第5章第4题
- 第5章第9题
- 第5章第10题
- 第6章 第5题
- 第7章 第5题
- hdu 1166敌兵布阵
- android apk 防止反编译技术第四篇-对抗JD-GUI
- 【2015/4/22】jsp学习笔记2--jsp基本语法+入门
- OpenWrt-路由器上的linux
- 借鉴drawable文件夹,使用dimens控制字体大小、边距大小。适配Android不同机型,不同屏幕
- 第3章 第5题
- [LeetCode] Happy Number
- 从零开始学习OpenWrt
- C和指针读书笔记-第4章(语句)
- sklearn源码学习笔记一:估计子基类base.py
- ray ban sunglasses outlet-349214
- 学习笔记-JAVA-考点10-什么情况下需要重写equals和hashcode()两个方法?
- MyEclipse10插件安装(二)
- UIView加边框及边框颜色