⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p311 9.5.cpp

📁 谭浩强 《C++ 程序设计》第三版的部分课后练习题源码
💻 CPP
字号:
#include<string>
#include<iostream>
using namespace std;
class Student
{
      public:
             Student(int a,string b,float c)
             {       num=a;
                     name=b;
                     score=c;
                         
             }
            friend void max(Student *p);
      private:
              int num;
              string name;
              float score;
      };
      
void max(Student *p)
{
     int i=0,number=0;
     float max=0;
     for(i=0;i<5;i++,p++)
      {
            if(max<p->score) 
               {
                             max=p->score;
                             number=p->num;
                             }
      }
      
      cout<<"the highest score is "<<max<<endl;
      cout<<"the number is :"<< number;
     
     
     }
     
     
int main()
{
     Student std[5]={
            Student(101,"wang",90),
            Student(102,"zhang",91),
            Student(103,"Li",92),
            Student(104,"song",94),
            Student(105,"lin",95)
                   };
     max(std);
     system("pause");
     return 0;
    
    
    
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -