time limit: 1 sec
memory limit: 128 mb
submit: 1013
solved: 735 [
submit][
status][
web board]
建立乙個物件陣列,內放n(<10)個學生的資料(學號、成績),設立乙個函式max,用指向物件的指標作函式引數,在max函式中找出n個學生中成績最高者,並輸出其學號。
n和n個學生的學號、成績
成績最高者的學號和成績
5101 78.5
102 85.5
103 98.5
104 100.0
105 95.5
104 100.00
主函式已給定如下,提交時不需要包含下述主函式
/* c++** */
int main()
int get_num();
void input();
double get_score();
void display();
private:
int num; //學號
double score; //成績
};int student::get_num()
double student::get_score()
void max(student *arr,int n)
no--;
arr[no].display();
}void student::input()
void student::display()
{ cout<>n;
for(i=0; i
C 習題 物件陣列求最大值
建立乙個物件陣列,內放n 10 個學生的資料 學號 成績 設立乙個函式max,用指向物件的指標作函式引數,在max函式中找出n個學生中成績最高者,並輸出其學號。n和n個學生的學號 成績 成績最高者的學號和成績 include includeusing namespace std class stud...
C 習題 物件陣列求最大值
建立乙個物件陣列,內放n 10 個學生的資料 學號 成績 設立乙個函式max,用指向物件的指標作函式引數,在max函式中找出n個學生中成績最高者,並輸出其學號。n和n個學生的學號 成績 成績最高者的學號和成績 5101 78.5102 85.5103 98.5104 100.0105 95.5 10...
python陣列求最大值最小值
剛剛面試被問到不用max函式怎麼求最大值,記錄一下 a 1 3,5 7,4 4,3 1,0 第一種方法 我們可以直接排序,取最後乙個 a.sort reverse false print a 1 第二種 我們定義第乙個元素 然後for迴圈比較 max num a 0 for i in range l...