题解 P5601 【小D与笔试】

ShineEternal

2019-10-28 12:18:19

Solution

[好东西](https://blog.csdn.net/kkkksc03/article/details/102778927) https://www.luogu.org/problem/P5601 ## solution: 这道题用string应该是比较好的(可以直接比较) 然后就是输入的四个选项可以一一判断,如果不想那么麻烦的就存在数组里就好了 ## code: ```cpp #include<cstdio> #include<iostream> #include<string> using namespace std; string t[105],ans[105],tm,a[5]; int main() { int n,q; scanf("%d%d",&n,&q); for(int i=1;i<=n;i++) { cin>>t[i]>>ans[i]; } for(int i=1;i<=q;i++) { cin>>tm>>a[1]>>a[2]>>a[3]>>a[4]; for(int j=1;j<=n;j++) { if(t[j]==tm) { for(int k=1;k<=4;k++) { if(a[k]==ans[j]) { printf("%c\n",k+'A'-1); } } } } } } ```