I wrote a code,it will find the max one and min one in an arr by vector
but I simply don't know what I've made an error.
Every time I try it return zero for me.lol
#include
#include
#include
using namespace std;
int main()
{
int a[999];
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
vector arr(a[1], a[n]);
int max = *max_element(arr.begin(), arr.end());
int min = *min_element(arr.begin(), arr.end());
int dis = max - min; cout << dis << endl;
return 0;
}
No comments:
Post a Comment