C/C++代码实现
解题思路:主要就是查询的问题,这里需要查询的是试机时的座位号,由于数据不是很大可以直接散列,然后直接输出。
#include<cstdio>
#include<cstring>
const int maxn=1005;
struct node{
char name[20];
int intest;
}stu[maxn];
int main(){
int N,M;
scanf("%d",&N);
char str[20];
int a,b;
for(int i=0;i<N;i++){
scanf("%s %d %d",str,&a,&b);
strcpy(stu[a].name,str);
stu[a].intest=b;
}
scanf("%d",&M);
for(int i=0;i<M;i++){
scanf("%d",&a);
printf("%s %d\n",stu[a].name,stu[a].intest);
}
return 0;
}

本文介绍了一种使用C/C++实现的简单座位查询系统。该系统通过散列的方式存储了学生的姓名和对应的试机座位号,实现了快速查询。文章提供了一个完整的代码示例,展示了如何读取学生信息并进行查询输出。

281

被折叠的 条评论
为什么被折叠?



