How can I use map !?

Sep 25, 2008 at 11:03am
Hi.
I just started to write a program with MAP and PAIR but I had some problems with it. I wanted to keep some pairs and wanted to later find them in O(lgn) so I wrote the code below :

#include <map>
#include <cstdio>

typedef pair<int,int> pairx;
map <pairx,int> mapx;

int main () {
int i,n,x,y,counter;
counter=0;
scanf("%d",&n);
for (i=0;i<n;i++) {
scanf("%d %d",&x,&y);
if (mapx.find(pairx(x,y))==mapx.end()) {
mapx[pairx(x,y)]=counter++;
}
}
scanf("%d %d",&x,&y);
printf("%d\n",mapx[pairx(x,y)]);
return 0;
}


I am a beginner and I know :D and I would be glad if anyone can help me ;).
Sorry for being too talkative


Oops the key type was pairx But still has bunch of compilation errors
Last edited on Sep 25, 2008 at 7:50pm
Sep 25, 2008 at 11:20am
What's the key type in mapx?
Topic archived. No new replies allowed.