Q:

How to find the values being swapped in two different arrays?

I am suppose to swap an array with the odds in one array and the evens in another while keeping track of the count and the values being swapped.
{2, 3, 6}
{1, 4, 7}

will become

{1, 3, 7}
{2, 4, 6}

With 2 swaps, and the values being swapped are
1 &2, 6 & 7.
int main() {
    int a1[3] = { 2, 3, 6 };
    int a2[3] = { 1, 4, 7 };
    int i;
    int swapcount = 0;
    int swapvalue;

    std::cout << "Before swap:\n" << endl;
    std::cout << "Array 1:\n" << endl;
    for (int i = 0; i < 3; i++) {
        cout << " " << a1[i] << endl;

    }
    std::cout << "Array 2:\n" << endl;
    for (int i = 0; i < 3; i++) {
        std::cout << " " << a2[i] << endl;

    }

    for (int i = 0; i < 3; i++) {
        if (a1[i] % 2 != 1) {
            swapcount++;
            int temp = a1[i];
            a1[i] = a2[i];
            a2[i] = temp;
            swapvalue = i;
        }
    }

    std::cout << "After swap:\n" << endl;
    std::cout << "Array 1:\n" << endl;
    for (int i = 0; i < 3; i++) {
        std::cout << " " << a1[i] << endl;
    }

    std::cout << "Array 2:\n" << endl;
    for (int i = 0; i < 3; i++) {
        std::cout << " " << a2[i] << endl;

    }

    std::cout << "swap count: " << swapcount << endl;
    std::cout << "swap value: " << swapvalue << endl;
}

So far, I have gotten the swap and counter to work but I cannot seem to figure out:
How to find and store the individual values of the elements that are swapped? (I can get only one value to show.)
Can I get any hints on how to all grab the values? I am not allowed to use any additional libraries except for the input and output streams. Thanks ahead of time.

A:

Create an auxiliary array swapbool, set boolean = 1 if a swap is done. 
#include<iostream>
using namespace std;
int main() {
    int a1[3] = { 2, 3, 6 };
    int a2[3] = { 1, 4, 7 };
    int swapbool[3] = {0,0,0};
    int i;
    int swapcount = 0;
    int swapvalue;

    std::cout << "Before swap:\n" << endl;
    std::cout << "Array 1:\n" << endl;
    for (int i = 0; i < 3; i++) {
        cout << " " << a1[i] << endl;

    }
    std::cout << "Array 2:\n" << endl;
    for (int i = 0; i < 3; i++) {
        std::cout << " " << a2[i] << endl;

    }

    for (int i = 0; i < 3; i++) {
        if (a1[i] % 2 != 1) {
            swapcount++;
            int temp = a1[i];
            a1[i] = a2[i];
            a2[i] = temp;
           // swapvalue = i;
            swapbool[i]=1;
        }
    }

    std::cout << "After swap:\n" << endl;
    std::cout << "Array 1:\n" << endl;
    for (int i = 0; i < 3; i++) {
        std::cout << " " << a1[i] << endl;
    }

    std::cout << "Array 2:\n" << endl;
    for (int i = 0; i < 3; i++) {
        std::cout << " " << a2[i] << endl;

    }

    std::cout << "swap count: " << swapcount << endl;
    for (int i = 0; i < 3; i++) {
        if(swapbool[i] == 1)
        {
            std::cout << "swapvalue1-> " << a2[i] << endl;
            std::cout << "swapvalue2-> " << a1[i] << endl;
        }
    }

    //std::cout << "swap value: " << swapvalue << endl;
}

