Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int N;
- cout << "Enter the size of arrays = ";
- cin >> N;
- int* a = new int[N];
- int* b = new int[N];
- cout << endl << "Fill the array:" << endl;
- for (int i = 0; i < N; i++) {
- cout << i + 1 << ") ";
- cin >> a[i];
- }
- int pos = 0;
- for (int i = 0; i < N; i++) {
- if (a[i] > 0) {
- b[pos] = a[i];
- pos++;
- }
- }
- cout << endl << "Array B:" << endl;
- for (int i = 0; i < pos; i++) {
- cout << i + 1 << ") " << b[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement