Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- const int bigSize{ 10 };
- const int smallSize{ bigSize / 2 };
- enum Condition{greater, equal, less, maxCond};
- int arrSmallA[smallSize]{ 1,2,-3,0,4 };
- int arrSmallB[smallSize]{ -1,0,3,6,-5 };
- int arrBig[bigSize]{};
- int bigIdx{ 0 };
- for (int cond{ Condition::greater }; cond < Condition::maxCond; ++cond)
- {
- for (int smallIdx{ 0 }; smallIdx < smallSize; ++smallIdx)
- {
- if (cond == Condition::greater)
- {
- if (arrSmallA[smallIdx] > 0) { arrBig[bigIdx++] = arrSmallA[smallIdx]; }
- if (arrSmallB[smallIdx] > 0) { arrBig[bigIdx++] = arrSmallB[smallIdx]; }
- }
- else if (cond == Condition::equal)
- {
- if (arrSmallA[smallIdx] == 0) { arrBig[bigIdx++] = arrSmallA[smallIdx]; }
- if (arrSmallB[smallIdx] == 0) { arrBig[bigIdx++] = arrSmallB[smallIdx]; }
- }
- else if (cond == Condition::less)
- {
- if (arrSmallA[smallIdx] < 0) { arrBig[bigIdx++] = arrSmallA[smallIdx]; }
- if (arrSmallB[smallIdx] < 0) { arrBig[bigIdx++] = arrSmallB[smallIdx]; }
- }
- }
- }
- for (bigIdx = 0; bigIdx < bigSize; ++bigIdx)
- {
- std::cout << arrBig[bigIdx] << ' ';
- }
- std::cout << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement