View Code of Problem 7

//
//  main.c
//  Problem7
//
//  Created by laojiaqi on 2019/3/16.
//  Copyright © 2019年 laojiaqi. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
    // insert code here...
    int t;
    scanf("%d",&t);
    for(int i=0;i<t;++i){
        int n;
        scanf("%d",&n);
        int num[2*n];
        for (int j=0; j<n; ++j) {
            //char *str;str=(char *)malloc(sizeof(char));
            char str[100];
            scanf("%s",str);
            char *p = strtok(str,"=");
            //char*temp = p;
            num[j] = atof(p);
            p = strtok(NULL," ");
            num[2*n-j-1] = atof(p);
            printf("%d %d",num[j],num[2*n-j]);
            free(str);
        }
        
        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;
                }
                if(l==2*n-1){
                    printf("UNKNOW");
                }
            }
            printf("\n");
        }
    }
  
    return 0;
}

Double click to view unformatted code.


Back to problem 7