String processing UVALive-6917 decoding Baby Boos

Source: Internet
Author: User
Tags printf

problem Description

Give you the T Group of data, each set of data to give you a string, with only uppercase letters or underscores. Give you M-group operations, each set of operations have U, v two capital letters, that is, the string inside all the letter V into the letter U

idea: Turn B into a, turn a into C, it's equivalent to turn B into C. That an array to save the last letter into that letter

#include <bits/stdc++.h> using namespace std;
Char s[1000055];
    int main () {int T, m;
    Char c1[2], c2[2];
    The int flag[30];//is used to save, and finally the letter becomes the letter scanf ("%d", &t);
        while (t--) {scanf ("%s", s);
        for (int i = 0; I <=; i++)//Initialize flag[i] = i;
        scanf ("%d", &m);
            while (m--) {scanf ("%s%s", C1, C2);
            int u = c1[0]-' a ';//convert integer int v = c2[0]-' a ';
                for (int i = 0; I <=; i++)//core {if (flag[i] = = v)//original flag[i] is the letter V, now let him become the letter U
                {Flag[i] = u;
        }}} int len = strlen (s);
                for (int i = 0; i < len; i++) {if (S[i] >= ' A ' && s[i] <= ' Z ')//if uppercase {
                int t = s[i]-' A ';
        printf ("%c", flag[t] + ' A ');//output changed result} else printf ("%c", S[i]); } printf ("\ n");
} return 0;
 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.