Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <time.h>
- using namespace std;
- void fillRandom (float* target, const unsigned int& length, const float& rmin, const float& rmax) {
- for (int i=0; i<length; i++) {
- target[i] = rmin + (float)rand()/RAND_MAX*(rmax-rmin);
- }
- }
- int _tmain(int argc, _TCHAR* argv[]) {
- srand(time(0));
- unsigned int n;
- cout << "Enter array length: ";
- cin >> n;
- float* numbers = new float[n];
- float rmin, rmax;
- cout << "Enter minimal and maximal random values: ";
- cin >> rmin >> rmax;
- fillRandom(numbers, n, rmin, rmax);
- cout << "Result: " << endl;
- for (int i=0; i<n; i++) {
- cout << numbers[i] << endl;
- }
- delete[] numbers;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement