Vla_DOS

Untitled

Jun 20th, 2022
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     setlocale(LC_CTYPE, "");
  7.     int n;
  8.     cin >> n;
  9.  
  10.     int* A = new int [n];
  11.  
  12.     for (int i = 0; i < n; i++)
  13.     {
  14.         A[i] = 20 + rand() % 47 - 10;
  15.     }
  16.     for (int i = 0; i < n; i++)
  17.     {
  18.         cout << A[i] << " ";
  19.     }
  20.     int max = A[0];
  21.     int maxi = 0;
  22.     for (int i = 0; i < n; i++)
  23.     {
  24.         if (max < A[i]) {
  25.             maxi = i;
  26.         }
  27.     }
  28.     A[maxi] = 100;
  29.     cout << "\n\n";
  30.     for (int i = 0; i < n; i++)
  31.     {
  32.         cout << A[i] << " ";
  33.     }
  34.     delete[] A;
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment