Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int _tmain(int argc, _TCHAR* argv[])
  8. {
  9.     setlocale(LC_ALL, "Russian");
  10.  
  11.     int size, k, x, i, r;
  12.     cout << "Введите размер массива: ";
  13.     cin >> size;
  14.     if (!cin){
  15.         cout << "Error";
  16.         return 1;
  17.     }
  18.  
  19.     cout << "\nВведите шаг: ";
  20.     cin >> k;
  21.     if (!cin){
  22.         cout << "Error";
  23.         return 1;
  24.     }
  25.  
  26.     int *arr = new int[size];
  27.  
  28.     for (int i = 0; i<size; i++) {
  29.         arr[i] = (rand() % 10 + 1);
  30.         cout << arr[i] << "\t";
  31.  
  32.     }
  33.     cout << endl;
  34.     for (i = k; (i - size) < k;) {
  35.        
  36.         if (i<size) cout << arr[i] << "\t";
  37.         else cout << arr[i-size]<<"\t";
  38.         i++;
  39.     }
  40.  
  41.     delete[]arr;
  42.     system("pause");
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement