Solution for Problem 4:


#include<iostream>
#define size 10     //size = sizeof(arr);
#define max 8       //max = maxof(arr[])+1;

using namespace std;

int main()
{
    int arr[] = {2,4,6,4,6,3,5,1,5,7}, hasharr[max] = {0}, i, sum=8;

    for(i=0; i<size; i++)
        hasharr[arr[i]] = 1;

    for(i=0; i<max; i++)
    {
        if((hasharr[i] != 0) && (hasharr[sum-i] != 0))
        {
            cout<<i<<"+"<<(sum-i)<<"="<<sum<<endl;
            hasharr[i] = hasharr[sum-i] = 0;
        }
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to