How use Upper_bound() function in a structure array

Post here if you don't find any other place for your post. But please, stay on-topic: algorithms, programming or something related to this web site and its services.

Moderator: Board moderators

Post Reply
Najmuzzaman
New poster
Posts: 3
Joined: Mon May 23, 2011 1:44 pm

How use Upper_bound() function in a structure array

Post by Najmuzzaman »

Code: Select all

#include <stdio.h>
#include <algorithm>
using namespace std;
struct node{
    int a,b;
}arr[10];

int main()
{
    for(i=0;i<10;i++)
    {
        arr[i].a=i+10;
        arr[i].b=i+12;
    }
    int it=(int)(upper_bound(arr,arr+10,10)-arr);
    printf("the position is %d");
}
Do not work
zobayer
Experienced poster
Posts: 110
Joined: Tue May 06, 2008 2:18 pm
Location: CSE-DU, Bangladesh
Contact:

Re: How use Upper_bound() function in a structure array

Post by zobayer »

you need to write a compare function that determines the behavior of your structre.
you can find out that from http://www.cplusplus.com
You should not always say what you know, but you should always know what you say.
Post Reply

Return to “Other words”