想了好久的题目,一直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;
        }
    }
}