how to compare vector pairs and pick the odd one out?

  algorithm, c++, std-pair, vector

how can i pick the different numbers of both numbers in a pair entry more efficiently

    if(loc[0].first!=loc[1].first && loc[0].first!=loc[2].first)
        x=loc[0].first;
    if(loc[1].first!=loc[0].first && loc[1].first!=loc[2].first)
        x=loc[1].first;
    if(loc[2].first!=loc[0].first && loc[2].first!=loc[1].first)
        x=loc[2].first;

    if(loc[0].second!=loc[1].second && loc[0].second!=loc[2].second)
        y=loc[0].second;
    if(loc[1].second!=loc[0].second && loc[1].second!=loc[2].second)
        y=loc[1].second;
    if(loc[2].second!=loc[0].second && loc[2].second!=loc[1].second)
        y=loc[2].second;

Source: Windows Questions C++

LEAVE A COMMENT