0
点赞
收藏
分享

微信扫一扫

PTA 天梯赛 L1-005 考试座位号

两岁时就很帅 2022-03-19 阅读 51
c++c语言

为了存储方便,那一大串数用string存储,拒绝排序,直接将他放到对应的试机座位号下标的string数组中,考试座位号也放在同一个下标的int类型数组中。读入试机号之后直接输出就ok

#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    //存入数据
    string *s=new string[n+1];
    int *arr=new int[n+1];
    string temp;
    int l1,l2;
    for(int i=0;i<n;i++)
    {
        cin>>temp>>l1>>l2;
        s[l1]=temp;
        arr[l1]=l2;
    }
    
    //查找信息
    cin>>n;
    int l;
    while(n>0)
    {
        cin>>l;
        cout<<s[l]<<' '<<arr[l]<<endl;
        n--;
    }
    return 0;
}
举报

相关推荐

0 条评论