蓝桥杯的一道题,,题目大概是把整数排序然后求平均数,当时用的sort,然后编译出错了,以下是答案,想问一下这题能用sort嘛?(我知道这种水平的题做不出来很丢脸,但是想问一下)
#include<iostream>
using namespace std;
int main()
{
int maxn = 0;
int minn = 2147483647;
int sum = 0;
for(int i = 1; i <= 10; i++)
{
int t;
cin >> t;
if(t > maxn)
{
maxn = t;
}
if(t < minn)
{
minn = t;
}
sum += t;
}
double avg = 1.0 * sum / 10;
cout << maxn << "," << minn << "," << avg << endl;
return 0;
}
蟹蟹