搜题
问题   更新时间2023/4/3 12:59:00

定义一个含有10个数的一维数组,按要求编写程序:
(1) 编写函数实现10个数据的输入。
(2) 编写函数求10个数的最大值。
(3) 在main函数中,调用以上函数,求10个数的最大值。

#include using namespace std; int main() { void input(float score[], int n); float smax(float score[], int n); float s[10]; input(s,10); cout << "The highest score: " << smax(s,10) << endl; return 0; } void input(float score[], int n) { for (int i = 0; i < n; i++) cin >> score[i]; } float smax(float score[], int n) { float max = score[0]; for( int i =1; i < n; i++) if (score[i] > max) max = score[i]; return max; }
王老师:19139051760(拨打)