Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- using namespace std;
- int k = 0;
- int* mas=nullptr, * mas2=nullptr;
- int n;
- cout << "Enter n: " << endl;
- cin >> n;
- int t;
- cout << "Enter t: " << endl;
- cin >> t;
- mas = new int[n];
- cout << "Enter mas: " << endl;
- for (int i = 0; i < n; i++)
- {
- cin >> mas[i];
- if (mas[i] % 5 == 0)
- {
- k++;
- }
- }
- mas2 = new int[n+k];
- for (int i = 0, j = 0; i < (n + k); i++)
- {
- mas2[j++] = mas[i];
- if (mas[i] % 5 == 0)
- {
- mas2[j++] = t;
- }
- }
- cout << "New:" << endl;
- for (int i = 0; i < (n + k); i++)
- {
- cout << mas2[i] << endl;
- }
- delete[] mas;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement