65,211
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<map>
#include<cstring>
using namespace std;
struct comp
{
bool operator()(const char* a,const char* b)
{
return strcmp(a,b)<0;
}
};
map<char*,int,comp>m;
int main()
{
int n;
scanf("%d\n",&n);
int i;
char *s;
for(i=0;i<n;i++)
{
s=new char[100];
gets(s);
m.insert(make_pair(s,i));
}
map<char*,int,comp>::iterator p=m.begin();
while(p!=m.end())
{
cout<<p->first<<" "<<p->second<<endl;
p++;
}
return 0;
}