View Code of Problem 7

#include <stdio.h>
int main(void) {
    // insert code here...
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;++i){
        int n;
        scanf("%d",&n);
        int num[2*n];
        for (int j=0; j<n; ++j) {
            char ch = getchar();
            num[j] = ch-'0';
            getchar();
            num[n-j] = ch-'0';
            //getchar();
        }
    }
    int m;
    scanf("%d",&m);
    for(int k=0;k<m;k++){
        int m1;
        scanf("%d",&m1);
        for(int l=0;l<n*2;l++){
            if(num[l]==m1){
                printf("%d\n",num[2*n-l]);
                break;
            }
        }
        printf("\n");
    }
    return 0;
}
/*
Main.c: In function 'main':
Main.c:9:13: warning: variable 'num' set but not used [-Wunused-but-set-variable]
         int num[2*n];
             ^
Main.c:23:23: error: 'n' undeclared (first use in this function)
         for(int l=0;l<n*2;l++){
                       ^
Main.c:23:23: note: each undeclared identifier is reported only once for each function it appears in
Main.c:24:16: error: 'num' undeclared (first use in this function)
             if(num[l]==m1){
                ^
*/

Double click to view unformatted code.


Back to problem 7