2019 freshman season %%% xxh

Notes .md 9/16/2019

%%%xxh

 

Topic background

A small ACM Association is a newly sprouting new, well-known acm training routine gangster film is so little water group A giant also joined the ranks of population%

Input Format

Each row (no more than 100 lines) is comprising a ':' spaced apart string S (| S | <= 100,) on behalf of a person and his words QQid

Output Format

For each person to say, if someone in front of him and said the same, then the output "%%%" + last person said this sentence QQid, if he said earlier, "+1", enter a say so, otherwise the output him this is the case. input sample 1

xxh:hehe ac:%%%xxh wa:xxhorz A:xxhtql

Sample Output

hehe

%%%xxh

xxhorz xxhtql

Sample input 2

xxh:abcdefg ac:abcdefg wa:+1 tle:wqe re:abcdefg

Sample Output 2

abcdefg %%%xxh abcdefg wqe

%%%ac

 

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int N = 110;
struct node {
    string name;
    string meg;
};
node a[N];
string s;
int main(int argc, char *argv[]) {
    int idx = 0,pos,sign;
    while(cin >> s) {
        sign = 0;
        pos = s.find(':');
        a[idx].name = s.substr(0,pos);//截取 
        a[idx].meg  = s.substr(pos+1,s.size()-pos-1);
        if(a[idx].meg == "+1") {
            cout << a[idx-1].meg << endl;
            sign = 1;
        }
        for(int i=idx-1; i>=0; --i) {
            if(a[i].meg == a[idx].meg) {
                cout << "%%%" << a[i].name << endl;
                sign = 1;
                break;
            }
        }
        if(!sign)   cout << a[idx].meg << endl;
        idx++;
    }
    return 0;
}

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/QingyuYYYYY/p/11817096.html