Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void replaceWith100(int* arr, int size) {
  5.     for (int i = 0; i < size; i++) {
  6.         if (arr[i] < 0) {
  7.             arr[i] = 100;
  8.         }
  9.     }
  10. }
  11.  
  12. int main() {
  13.     int size;
  14.  
  15.     cout << "Введите размер: ";
  16.     cin >> size;
  17.  
  18.     int* array = new int[size];
  19.  
  20.     cout << "Введите содержимое: " << endl;
  21.     for (int i = 0; i < size; i++) {
  22.         cout << i << ": ";
  23.         cin >> array[i];
  24.     }
  25.  
  26.     replaceWith100(array, size);
  27.  
  28.     cout << "Получившийся массив: ";
  29.     for (int i = 0; i < size; i++) {
  30.         cout << array[i] << " ";
  31.     }
  32.  
  33.     delete[] array;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement