zoukankan      html  css  js  c++  java
  • 题目记录2

    想了好久的题目,一直submit failed,桑心,但是感觉自己应该对了

    题目:http://vj.bit-studio.cn/contest/209424#problem/B

    方法&收获:string可以用下标例如string str=“abc”;str[0]就应该等于’a‘。

    #include<string>
    #include<iostream>
    #include<cstdlib>
    #include<cstdio>
    #include<map>
    #include<vector>
    using namespace std;
    map<string, string>tra;
    int main()
    {
        string fla;
        cin >> fla;
        if (fla == "START")
        {
            while (1)
            {
                string temp1, temp2;
                cin >> temp1;
                if (temp1 == "END")break;
                else
                {
                    cin >> temp2;
                    tra[temp1] = temp2;
                }
            }
            string temp3;
            while (1)
            {
                getline(cin, temp3);
                if (temp3 == "START")continue;
                if (temp3 == "END")break;
                for (int i = 0, j = 0; i < temp3.length(); i++)
                {
                    if ((temp3[i] <= 'z'&&temp3[i] >= 'a') || (temp3[i] <= 'Z'&&temp3[i] >= 'A'));
                    else
                    {
                        if (j != i)
                        {
                            string temp4(temp3, j, i - j);
                            map<string, string>::iterator iter;
                            bool fla = false;
                            for (iter = tra.begin(); iter != tra.end(); iter++)
                            {
                                if (iter->second == temp4)
                                {
                                    cout << iter->first;
                                    fla = true;
                                    break;
                                }
                            }
                            if (!fla)cout << temp4;
                        }
                        cout << temp3[i];
                        j = i + 1;
                    }
                }
                cout << endl;
            }
        }
    }
  • 相关阅读:
    shell脚本sed的基本用法
    shell grep的基本用法
    禁止表单提示输入--autocomplete属性
    Cookie操作介绍
    JSP中的两种重定向
    SSM
    题解 P4994 【终于结束的起点】
    题解 P1286 【两数之和】
    题解 P2340 【奶牛会展】
    题解 CF450B 【Jzzhu and Sequences】
  • 原文地址:https://www.cnblogs.com/miaos/p/miaoz-1-10.html
Copyright © 2011-2022 走看看