标签:
Do you know password table? A password table is used to protect the security of the online account. When a user needs to login to his/her online account or pay for money, he/she may need to fill in the password according to his/her own password table. For example, if one user has the following table and the online system requires him/her to input the password of “A4B7D1”, he/she may input “577000”.
The first line of the input contains an integer T(T≤100), indicating the number of test cases. The first line of each case contains three numbers n(5≤n≤9), m(5≤m≤9) and q(1≤q≤100) representing the length and width of the password table, and the total number of queries (Look at the password table above, its length is 8 and its width is 5). Each of the following n lines contains m numbers, representing the given password table.
Then, each of the following q lines represents a query with the format of "L1D1L2D2L3D3" (L1, L2 and L3 are letters. D1, D2 and D3 are digits), just like the example in paragraph one.
For each test case, print a line containing the test case number (beginning with 1). For each query in one test case, please output its corresponding password in one line.
用三维数组水水的模拟一下就好了
#include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <algorithm> #include <set> #include <queue> #include <stack> #include <map> using namespace std; typedef long long LL; const int inf=0x3f3f3f3f; const double pi= acos(-1.0); char a[10][10][1010]; int main() { int T,n,m,q,i,j; int icase; char str[110]; scanf("%d",&T); for(icase=1;icase<=T;icase++){ scanf("%d %d %d",&n,&m,&q); for(i=1;i<=n;i++) for(j=0;j<m;j++) scanf("%s",&a[i][j]); printf("Case %d:\n", icase); while(q--){ scanf("%s",str); int len=strlen(str); for(i=0;i<len;i+=2){ printf("%s",a[str[i+1]-'0'][str[i]-'A']); } puts(""); } } return 0; }
标签:
原文地址:http://blog.csdn.net/u013486414/article/details/44752945