Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cstdlib>
  3. #include <string.h>
  4.  
  5. int findIndex(char keys[], char target){
  6.     for(int i=0;i<26;i++){
  7.         if(keys[i]==target){
  8.             return i;
  9.         }
  10.     }
  11. }
  12.  
  13. int main(){
  14.     int tc;
  15.     scanf("%d",&tc);
  16.     char temp[26];
  17.     const char normal[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  18.     for(int i=1;i<=tc;i++){
  19.         int n,m,in,index=0;
  20.         scanf("%d %d",&n,&m);
  21.         char keys[n][26];
  22.         char words[m];
  23.         for(int j=0;j<n;j++){
  24.             scanf("%s",temp);
  25.             strcpy(keys[j],temp);
  26.         }
  27.         scanf("%s",words);
  28.         for(int j=0;j<m;j++){
  29.             scanf("%d",&in);
  30.             words[j] = normal[findIndex(keys[in-1],words[j])];
  31.         }
  32.         printf("Case #%d: %s\n",i,words);
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement