Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- const int arrSmallSize{ 5 };
- const int arrBigSize{ arrSmallSize * 2 };
- enum Conditions {greater, equal, less, maxConditions};
- int arrSmallA[arrSmallSize]{1,-4,-5,0,2};
- int arrSmallB[arrSmallSize]{-5,0,7,4,-1};
- int arrBig[arrBigSize]{}; //1 7 2 4 0 0 -5 -4 -5 -1
- int bigIdx{ 0 };
- for (int i{ 0 }; i < arrSmallSize; ++i) { std::cout << arrSmallA[i] << '\t'; } std::cout << '\n';
- for (int i{ 0 }; i < arrSmallSize; ++i) { std::cout << arrSmallB[i] << '\t'; } std::cout << '\n';
- //for (int smallIdx{ 0 }; smallIdx < arrSmallSize; ++smallIdx)
- //{
- // if (arrSmallA[smallIdx] > 0) { arrBig[bigIdx++] = arrSmallA[smallIdx]; }
- // if (arrSmallB[smallIdx] > 0) { arrBig[bigIdx++] = arrSmallB[smallIdx]; }
- //}
- //for (int smallIdx{ 0 }; smallIdx < arrSmallSize; ++smallIdx)
- //{
- // if (arrSmallA[smallIdx] == 0) { arrBig[bigIdx++] = arrSmallA[smallIdx]; }
- // if (arrSmallB[smallIdx] == 0) { arrBig[bigIdx++] = arrSmallB[smallIdx]; }
- //}
- //for (int smallIdx{ 0 }; smallIdx < arrSmallSize; ++smallIdx)
- //{
- // if (arrSmallA[smallIdx] < 0) { arrBig[bigIdx++] = arrSmallA[smallIdx]; }
- // if (arrSmallB[smallIdx] < 0) { arrBig[bigIdx++] = arrSmallB[smallIdx]; }
- //}
- for (int condition{ 0 }; condition < Conditions::maxConditions; ++condition)
- {
- for (int smallIdx{ 0 }; smallIdx < arrSmallSize; ++smallIdx)
- {
- if (condition == Conditions::greater)
- {
- if (arrSmallA[smallIdx] > 0) { arrBig[bigIdx++] = arrSmallA[smallIdx]; }
- if (arrSmallB[smallIdx] > 0) { arrBig[bigIdx++] = arrSmallB[smallIdx]; }
- }
- else if (condition == Conditions::equal)
- {
- if (arrSmallA[smallIdx] == 0) { arrBig[bigIdx++] = arrSmallA[smallIdx]; }
- if (arrSmallB[smallIdx] == 0) { arrBig[bigIdx++] = arrSmallB[smallIdx]; }
- }
- else if (condition == Conditions::less)
- {
- if (arrSmallA[smallIdx] < 0) { arrBig[bigIdx++] = arrSmallA[smallIdx]; }
- if (arrSmallB[smallIdx] < 0) { arrBig[bigIdx++] = arrSmallB[smallIdx]; }
- }
- }
- }
- for (int bigIdx{ 0 }; bigIdx < arrBigSize; ++bigIdx) { std::cout << arrBig[bigIdx] << '\t'; } std::cout << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement