PATb 1041 考试座位号 (15分)
题目简单,贴代码就好了,用string来解决字符串,cin
代码:
#include <iostream>
using namespace std;
struct stu {
string id;
int test_id,exam_id;
};
int main(){
int n,m,k,shi,kao;
string temp;
scanf("%d",&n);
stu peo[n+1];
for(int i = 1;i<=n;i++){
cin >>temp;
scanf("%d %d",&shi,&kao);
peo[shi].id = temp;
peo[shi].test_id = shi;
peo[shi].exam_id = kao;
// scanf("%d %d",&peo[i].test_id,&peo[i].exam_id);
}
/* for(int i = 1;i<=n;i++){
//scanf("%d",&k);
printf(" %d = %d ",i,peo[i].exam_id);
cout<<peo[i].id<<endl;
// printf(" %d = %d\n",i,peo[i].exam_id);
}*/
scanf("%d",&m);
for(int i = 1;i<=m;i++){
scanf("%d",&k);
cout<<peo[k].id;
printf(" %d\n",peo[k].exam_id);
}
return 0;
}
}
GOGOGOGO!
Love Joyee forever!