Advertisement
shaba16

dz_number_11

Nov 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     //////////////////////////////////// 11Б
  8.  
  9.  
  10.     const int n = 10;
  11.     int x[n];
  12.     int y[n];
  13.     int z[n];
  14.     int mass[n];
  15.  
  16.     cout << "Enter massive x[" << n << "] :" << endl;
  17.     for (int i = 0; i < n; i++)
  18.     {
  19.         x[i] = rand() % 100;
  20.         cout << "x[" << i + 1 << "]= " << x[i] << endl;
  21.     }
  22.     cout << endl;
  23.  
  24.     ////////////////////////////////////////////////////////
  25.  
  26.     cout << "Enter massive y[" << n << "] :" << endl;
  27.  
  28.     for (int i = 1; i <= n; i++)
  29.     {
  30.         y[i - 1] = x[i];
  31.         y[n-1] = x[0];
  32.         cout << "y[" << i << "] =" << y[i - 1] << endl;
  33.     }
  34.  
  35.     for (int i = n-1; i >= 1; i--)
  36.     {
  37.         z[i] = x[i-1];
  38.         z[0] = x[n-1];
  39.     }
  40.  
  41.     cout << endl;
  42.     /////////////////////////////////////////////////////
  43.  
  44.     cout << "Enter massive z[" << n << "] :" << endl;
  45.    
  46.     for (int i = 0; i < n; i++)
  47.     {
  48.         cout << "z[" << i + 1 << "]= " << z[i] << endl;
  49.     }
  50.  
  51.     //////////////////////////////////////// 11Г
  52.     cout << endl;
  53.  
  54.     int p;
  55.  
  56.     for (int i = 1; i < n; i + 2)
  57.     {
  58.         p = x[i];
  59.         x[i] = x[i + 1];
  60.         x[i + 1] = p;
  61.     }
  62.     p = x[0];
  63.     x[0] = x[n - 1];
  64.     x[n - 1] = p;
  65.  
  66.     cout << "Enter massive mass[" << n << "] :" << endl;
  67.  
  68.     for (int i = 0; i < n; i++)
  69.     {
  70.         mass[i] = x[i];
  71.         cout << "mass[" << i + 1 << "]= " << mass[i] << endl;
  72.     }
  73.  
  74.     system("pause");
  75.  
  76.     return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement