karol_dziachan

task1TEP

Oct 8th, 2020
1,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1.  
  2. void fillArray(int* array, int& arrLength)
  3. {
  4.     for (int i = 0; i < arrLength; i++)
  5.     {
  6.         *array = i + 5;
  7.         array++;
  8.     }
  9. }
  10.  
  11. void printArray(int* array, int& arrLength)
  12. {
  13.     cout << "Matrix: " <<  endl;
  14.     for (int i = 0; i < arrLength; i++)
  15.     {
  16.         cout << *array << endl;
  17.         array++;
  18.     }
  19. }
  20. void v_alloc_table_add_5(int iSize)
  21. {
  22.     int *arr;
  23.     arr = new int[iSize];
  24.     fillArray(arr, iSize);
  25.     printArray(arr, iSize);
  26.     delete[] arr;
  27. }
  28.  
  29.  
  30.  
  31. int main()
  32. {
  33.     int *iSize = new int;
  34.     cout << "Enter the size of the array" << endl;
  35.     cin >> *iSize;
  36.         while (*iSize < 0)
  37.         {
  38.             cout << "The size can not be less then zero. Try once again" << endl;
  39.             cin >> *iSize;
  40.         }
  41.    
  42.    
  43.  
  44.     v_alloc_table_add_5(*iSize);
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment