Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <ctime>
- #include <windows.h>
- using namespace std;
- void clampArr(int *arr, int size, int min, int max)
- {
- for(int i = 0; i < size; i++)
- {
- if(arr[i] < min) arr[i] = min;
- else if(arr[i] > max) arr[i] = max;
- }
- }
- int main()
- {
- int array[15];
- srand(time(NULL));
- for(int i = 0; i < 15; i++)
- array[i] = rand() % 15;
- clampArr(array, 15, 4, 8);
- for(int i = 0; i < 15; i++)
- cout << array[i] << " ";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment