Create a function that will have two integer parameters a and b, and return a random integer from the interval [a; b] as its value. C using this function to fill an array of 20 integers and display it on the screen. Help me please. It is necessary that this function generates different numbers.
#include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int cluchaynoechislo(int a, int b) // функция принимает 2 целочисленных параметра и возвращает в качестве своего значения целое число из отрезка [a;b]. { srand((unsigned)time(NULL)); unsigned const int n = 20; int A[n]; int cluchchislo; for(int i = 0; i < n; i++) { cluchchislo = a + rand() % (b - a); A[i] = cluchchislo; } return cluchchislo; } int _tmain(int argc, _TCHAR* argv[]) { setlocale(0,""); // русификация int a, b; cout << "Введите первое число: "; cin >> a; cout << "Введите второе число: "; cin >> b; unsigned const int n = 20; int A[n]; cout << "Элементы массива A: "; for (int i = 0; i < n; i++) { A[i] = cluchaynoechislo(a,b); cout << A[i] << " "; } cout << endl; system("pause"); return 0; }