chillurbrain

Task11_7_1

Dec 23rd, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <ctime>
  4. #include <windows.h>
  5.  
  6. using namespace std;
  7.  
  8. void clampArr(int *arr, int size, int min, int max)
  9. {
  10.     for(int i = 0; i < size; i++)
  11.     {
  12.         if(arr[i] < min) arr[i] = min;
  13.         else if(arr[i] > max) arr[i] = max;
  14.     }
  15. }
  16.  
  17. int main()
  18. {
  19.     int array[15];
  20.     srand(time(NULL));
  21.     for(int i = 0; i < 15; i++)
  22.         array[i] = rand() % 15;
  23.     clampArr(array, 15, 4, 8);
  24.     for(int i = 0; i < 15; i++)
  25.         cout << array[i] << " ";
  26.     system("pause");
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment