Advertisement
Bohmirov

ARR-8

Oct 10th, 2020 (edited)
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     setlocale(LC_ALL, "Russian");
  7.  
  8.     int a[10], n = 10;
  9.  
  10.     for (int i = 0; i < n; i++)
  11.     {
  12.         cout << "Введите " << i << " эл. массива: ";
  13.         cin >> a[i];
  14.     }
  15.  
  16.     for (int i = 0; i < n; i++)
  17.     {
  18.         if (a[i] < 0) {
  19.             a[i] = abs(a[i]);
  20.         }
  21.         else {
  22.             a[i] *= a[i];
  23.         }
  24.     }
  25.  
  26.     cout << "Изменённый массив:" << endl;
  27.     for (int i = 0; i < n; i++)
  28.     {
  29.         cout << a[i] << " ";
  30.     }
  31.     cout << endl;
  32.  
  33.     system("pause");
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement