|
本题添加时间:2023/4/3 12:59:00 |
|
圆梦客服:王老师 19139051760(微信同号) 19139051760(微信同号) |
定义一个含有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; }
出自
南阳师范学院-计算机网络技术 江开系统
南阳师范学院
|
更多试题>>>>
1、. , 。赖有南园菊,残花足解愁。(庾信《秋日诗》)
2、 给出一个百分制的成绩,要求输出成绩等级’A’,’B’,’C’,
’D’,’E’。90分以上为’A’,80~89分为’B’,70~79为’C’,60~69为’D’,60分以下为’E’。
3、9.其形也,翩若惊鸿,婉若游龙。荣耀秋菊,华茂春松。 , 。(曹植《洛神赋》)
4、8.相去日已远,衣带日已缓。 , 。(《古诗十九首行行重行行》)
5、除环除了零理想和单位理想还有其它理想。
|