Last active
January 18, 2016 20:43
-
-
Save andreuinyu/cff77a19ed109effe62e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
struct p{ | |
int a; | |
int b; | |
}; | |
p mam(int x, vector<int>& v){ | |
int i=0, f=v.size()-1; | |
p q; | |
while (true){ | |
int S=v[i]+v[f]; | |
if (S==x){ | |
q.a=v[i]; | |
q.b=v[f]; | |
return q; | |
} | |
if (S > x) f--; | |
if (S < x) i++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment