//这一题操作符又写错了
//bool operator<(const 结构体名字 & b)const{
//};
//这一题使用二分查找的原因在于N<1000不代表每一个学生的id不会大于1000
//使用打表法太耗内存
//strcmp函数的返回值不是bool!!!返回值小于零表示前面小,返回值为0表示相等
//以后使用strcmp的时候一定跟0比较之后放在if里面
//字符串赋值使用strcpy,直接赋值连门都没有
//二分查找的算法写错了。。。我就知道。。。
//以后给我记住了,二分的while()里面是l<=r
//二分判断之后l=mid+1;或者r=mid-1;不是直接赋值为mid!
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
struct stu{
char no[100];
char na[10];
char se[10];
int ag;
bool operator < (const stu & b)const {
int tmp=strcmp(no,b.no);
return tmp<0;
}
}buf[1001];
int main()
{
int n;
int n2;
while(scanf("%d",&n)!=EOF)
{
//这里求max其实没啥用就是用一下strcmp函数和strcpy函数
char max[100]={0};
for(int i=0;i<n;i++)
{
scanf("%s%s%s%d",&buf[i].no,&buf[i].na,&buf[i].se,&buf[i].ag);
if(strcmp(max,buf[i].no)<0)//strcmp函数的返回值不是bool!!!返回值小于零表示前面小,返回值为0表示相等
{
strcpy(max,buf[i].no);
}
}
sort(buf,buf+n);
// for(int i=0;i<n;i++)
// {
// printf("%s%s%s%d\n",buf[i].no,buf[i].na,buf[i].se,buf[i].ag);
// }
scanf("%d",&n2);
for(int i=0;i<n2;i++)
{
char tmp[100]={0};
scanf("%s",&tmp);
int l=0;
int r=n-1;int mid;
bool findtrue=0;
while(l<=r)
{
mid=(l+r)/2;
int tm=strcmp(buf[mid].no,tmp);
if(tm<0)
{
l=mid+1;
}
else if(tm>0)
{
r=mid-1;
}
else
{
printf("%s %s %s %d\n",buf[mid].no,buf[mid].na,buf[mid].se,buf[mid].ag);
findtrue=1;
break;
}
}
if(!findtrue)
printf("No Answer!\n");
}
}
return 0;
}
//bool operator<(const 结构体名字 & b)const{
//};
//这一题使用二分查找的原因在于N<1000不代表每一个学生的id不会大于1000
//使用打表法太耗内存
//strcmp函数的返回值不是bool!!!返回值小于零表示前面小,返回值为0表示相等
//以后使用strcmp的时候一定跟0比较之后放在if里面
//字符串赋值使用strcpy,直接赋值连门都没有
//二分查找的算法写错了。。。我就知道。。。
//以后给我记住了,二分的while()里面是l<=r
//二分判断之后l=mid+1;或者r=mid-1;不是直接赋值为mid!
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
struct stu{
char no[100];
char na[10];
char se[10];
int ag;
bool operator < (const stu & b)const {
int tmp=strcmp(no,b.no);
return tmp<0;
}
}buf[1001];
int main()
{
int n;
int n2;
while(scanf("%d",&n)!=EOF)
{
//这里求max其实没啥用就是用一下strcmp函数和strcpy函数
char max[100]={0};
for(int i=0;i<n;i++)
{
scanf("%s%s%s%d",&buf[i].no,&buf[i].na,&buf[i].se,&buf[i].ag);
if(strcmp(max,buf[i].no)<0)//strcmp函数的返回值不是bool!!!返回值小于零表示前面小,返回值为0表示相等
{
strcpy(max,buf[i].no);
}
}
sort(buf,buf+n);
// for(int i=0;i<n;i++)
// {
// printf("%s%s%s%d\n",buf[i].no,buf[i].na,buf[i].se,buf[i].ag);
// }
scanf("%d",&n2);
for(int i=0;i<n2;i++)
{
char tmp[100]={0};
scanf("%s",&tmp);
int l=0;
int r=n-1;int mid;
bool findtrue=0;
while(l<=r)
{
mid=(l+r)/2;
int tm=strcmp(buf[mid].no,tmp);
if(tm<0)
{
l=mid+1;
}
else if(tm>0)
{
r=mid-1;
}
else
{
printf("%s %s %s %d\n",buf[mid].no,buf[mid].na,buf[mid].se,buf[mid].ag);
findtrue=1;
break;
}
}
if(!findtrue)
printf("No Answer!\n");
}
}
return 0;
}