zoukankan      html  css  js  c++  java
  • Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)

    题目链接:http://codeforces.com/contest/831/problem/B

    题意:给第2个26个字母并不重复的字符串(2个字符串对于一个映射),第1个字符串为key集合,第2个字符串为对应的value集合。 然后给了一个字符串(包括小写字母和数字),按照映射规则输出结果(数字不变,字母则对照给定2个字符串的映射规则,大写字母先转换成对应小写字母然后映射完之后在转换成对应的大写字母)

    思路:按照题目意思模拟即可。

    #define _CRT_SECURE_NO_DEPRECATE
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<string>
    #include<queue>
    #include<vector>
    #include<time.h>
    #include<stack>
    #include<cmath>
    #include<functional>
    #include<cstdlib>
    using namespace std;
    typedef long long int LL;
    typedef unsigned long long int ULL;
    const LL INF = 9223372036854775807L;
    const int inf = 0x3f3f3f3f;
    const int MAXN = 1000 + 24;
    char str[MAXN],zd[MAXN];
    char c1[MAXN], c2[MAXN];
    int main(){
    #ifdef kirito
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
        int start = clock();
        while (~scanf("%s",c1)){
            scanf("%s", c2);
            scanf("%s", str);
            for (int i = 0; i < 26; i++){
                zd[c1[i] - 'a'] = c2[i];
            }
            for (int i = 0; i < strlen(str); i++){
                if (str[i] >= '0'&&str[i] <= '9'){
                    continue;
                }
                else if (str[i] >= 'A'&&str[i] <= 'Z'){
                    str[i] = (zd[str[i] - 'A'] - 'a' + 'A');
                }
                else{
                    str[i] = zd[str[i] - 'a'];
                }
            }
            printf("%s
    ", str);
        }
    #ifdef LOCAL_TIME
        cout << "[Finished in " << clock() - start << " ms]" << endl;
    #endif
        return 0;
    }
  • 相关阅读:
    CH6201走廊泼水节
    P3366 (模板)最小生成树
    linux 基础语法
    django 3.1 序列化讲述
    django 的基础设计
    django 的初始项目结构
    http
    mysql(一)
    反射型xss
    html(四)
  • 原文地址:https://www.cnblogs.com/kirito520/p/7246923.html
Copyright © 2011-2022 走看看