Ви
Виталий
Написать функцию, которая вычисляет количество элементов массива, лежащих в диапазоне от А до В
на языке с++, именно функция нужна
на языке с++, именно функция нужна
#include
#include
#include
using namespace std;
size_t count(int *, const size_t, const int, const int);
int main () {
locale::global(locale(""));
srand(unsigned(time(0)));
const size_t size = 13;
int arr[size];
for (size_t n = 0; n < size; n++) arr[n] = 999 - rand() % 1999;
for (size_t n = 0; n < size; n++) cout << setw(6) << arr[n];
cout << "\n Введите A и B: ";
int a, b;
cin >> a >> b;
cout << "\n Количество: " << count(arr, size, a, b) << endl;
cin.get(); cin.get();
return 0;
}
size_t count(int * _array, const size_t _size, const int _a, const int _b) {
size_t q = 0;
for (size_t n = 0; n < _size; n++) if (_array[n] > _a && _array[n] < _b) ++q;
return q;
}