Created
          January 5, 2016 20:01 
        
      - 
      
- 
        Save andrei14vl/a7098a04f11d3073c404 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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 <algorithm> | |
| using namespace std; | |
| struct MyType { | |
| int val; | |
| int extra; | |
| } arr[100]; | |
| bool cmp(int val, MyType my_object) { | |
| if (my_object.val < val) | |
| return false; | |
| return true; | |
| } | |
| int main() { | |
| int n = 10; | |
| for (int i = 1; i <= 10; ++i) { | |
| arr[i].val = i * 2; | |
| } | |
| int val; | |
| cin >> val; | |
| cout << upper_bound(arr + 1, arr + n + 1, val, cmp) - arr; | |
| return 0; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment