ZOJ 1831 Substitution Cypher

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
using namespace std;
char key[256];
char value[256];
int len_key;
int fi(char c)
{
    for(int i=0;i<len_key;++i)
    {
        if(c==key[i])
            return i;
    }
    return -1;
}
int main()
{
    //freopen("in.txt","r",stdin);
    gets(key);
    gets(value);
    printf("%s\n",value);
    printf("%s\n",key);

    len_key=strlen(key);
    char str[256];
    while(gets(str))
    {
        if(strcmp(str,"")==0)
            break;
        int len=strlen(str);
        for(int i=0;i<len;i++)
        {
            int res=fi(str[i]);
            printf("%c",res!=-1?value[res]:str[i]);
        }
        printf("\n");
    }
    return 0 ;
}

你可能感兴趣的:(ZOJ 1831 Substitution Cypher)