2023-07-26 11:02发布
提供一个思路吧,把数组排序就可以了#p##include #include int main(){ using name
#include <iostream>#include <valarray>int main(){ using namespace std; valarray<double> number(5); cout << "请输入5个浮点数: "; for(int i = 0;i < 5;i++) cin >> number[i]; cout << "平均数为: " << number.sum()/5 << endl; cout << "最大数为: " << number.max() << endl; cout << "最小数为: " << number.min() << endl; return 0;}本回答被提问者采纳
最多设置5个标签!
#include <iostream>
#include <valarray>
int main()
{
using namespace std;
valarray<double> number(5);
cout << "请输入5个浮点数: ";
for(int i = 0;i < 5;i++)
cin >> number[i];
cout << "平均数为: " << number.sum()/5 << endl;
cout << "最大数为: " << number.max() << endl;
cout << "最小数为: " << number.min() << endl;
return 0;
}本回答被提问者采纳
一周热门 更多>