热门

最新

红包

立Flag

投票

同城

我的

发布
m0_56918965
m0_56918965
4 年前
truem0_56918965

取数组中最大值,这样输出是对的,但是如果删去cout <<score[5] 输出的就不对,为什么呢?输出的是不是地址?
#include <iostream>
using namespace std;

int getmax(int arr[])
{
int i = 0;
int max = 0;
max = arr[0];
for (i = 0; i < 16; i++) {
if (arr[i] > max)
{
max = arr[i];
}
}
return max;
}
int main() {
int n = 0;
int scores[] = { 16,15,85,89,79,78,99,100,85,97,87 };
n = sizeof(scores) / sizeof(int);
cout << "学生数:" << n << endl;
cout << getmax(scores);
cout << scores[5];
return 0;
}

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
never enter one’s mind
立即登录