首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

学生种 指向对象的指针 模模糊糊的做出来了

2013-04-05 
学生类指向对象的指针模模糊糊的做出来了/** 程序的版权和版本声明部分* Copyright (c)2012, 烟台大学计算

学生类 指向对象的指针 模模糊糊的做出来了

/** 程序的版权和版本声明部分* Copyright (c)2012, 烟台大学计算机学院学生* All rightsreserved.* 文件名称: x.cpp* 作者:徐本锡* 完成日期: 2013年 4 月3  日* 版本号: v1.0* 输入描述:  * 问题描述:   学生类   指针。。。  * 程序输出:  *///我的代码:#include <iostream>#include <stdlib.h>using namespace std; class Student{public :    Student(int a,double b):num(a),score(b){}    void out();    int get_num(){return num;};    double get_score(){return score;};private :    int num;    double score;};void Student::out(){    cout<<"学号:"<<num<<"  分数:"<<score<<endl;}  double max(Student *arr);      //函数声明               int main(){    Student s1[5]={Student(4310,89.5),Student(4311,95.5),Student(4312,91.9),Student(4313,100),Student(4314,92.5)};    int i;    for( i=0;i<5;i++)    {if(i+1==1||i+1==3||i+1==5){cout<<"第"<<i+1<<"个";s1[i].out();}    }cout<<"成绩最好的是:"<<max(s1)<<endl;;return 0;}double max(Student *arr){    int i,n=0;    double max=arr[0].get_score();    for(i=1;i<5;i++)    {        if(arr[i].get_score()>max){            max=arr[i].get_score();n=i;}    }    return arr[n].get_num();                }


 

 

学生种      指向对象的指针    模模糊糊的做出来了

 

热点排行