Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. //6-5-10
  2. #include <iostream>
  3. #include <cmath>
  4. #include <iomanip>
  5. #include <clocale>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. int n, znak=0, x;
  12. cin >> n;
  13. int* arr = new int[n];
  14. for (int i = 0; i < n; i++)
  15. cin >> arr[i];
  16. for (int i = n - 1; i >= 0; i--)
  17. if (arr[i] % (i + 1) == 0)
  18. {
  19. znak = i;
  20. break;
  21. }
  22. cin >> x;
  23. for (int i = n; i > znak + 1; i--)
  24. arr[i] = arr[i - 1];
  25. arr[znak + 1] = x;
  26. n++;
  27. for (int i = 0; i < n; i++)
  28. cout << arr[i] << " ";
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement