• UVa 814


    题意

    模拟mta发送邮件
    模拟的我头皮发麻

    记录

    有个挺骚的操作记下来了, 有点意思

    string text;
    while(getline(cin, s) && s[0] != '*')
                text += "     " + s + "
    ";

    AC代码

    #include <iostream>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <set>
    #include <map>
    
    using namespace std;
    
    set<string> email, wait;
    vector<string> vec;
    map<string,vector<string> > countnum;
    
    void findmta( string &name, string &mta, string s ){
        int mrk = s.find('@');
        name = s.substr(0,mrk);
        mta = s.substr(mrk+1);
        //cout << name << endl << mta << endl;
    }
    
    int main()
    {
        string s, s1, s2, ss, name1, mta1, name2, mta2;
        vector<string>::iterator it;
        int n;
        size_t i, j;
        while( cin >> s )
        {
            if( s == "*" )  break;
            if( s == "MTA" ){
                cin >> s1;
                cin >> n;
                while(n--){
                    s2 = "";
                    cin >> s2;
                    email.insert(s2+"@"+s1);
                }
            }
        }
        while( cin >> s && s != "*" )
        {
            findmta(name1,mta1,s);
            while( cin >> ss && ss != "*" )
            {
                findmta(name2, mta2, ss);
                if(wait.count(ss)) continue;
                wait.insert(ss);
                if( !countnum.count(mta2) ){
                    vec.push_back(mta2);
                    countnum[mta2] = vector<string>();
                }
                countnum[mta2].push_back(ss);
                //countnum[mta2]++;
            }
            getchar();
            string text;
            while(getline(cin, s) && s[0] != '*')
                text += "     " + s + "
    ";
            for( i = 0; i < vec.size(); i++ ){
                vector<string> adds = countnum[vec[i]];
                cout << "Connection between " << mta1 << " and " << vec[i] << endl;
                cout << "     HELO " << mta1 << endl << "     250" << endl;
                cout << "     MAIL FROM:<" << name1 << "@" << mta1 << ">" << endl << "     250" << endl;
                bool flag = false;
                for( j = 0; j < adds.size(); j++){
                    cout << "     RCPT TO:<" << adds[j] << ">" << endl;
                    if( email.count(adds[j]) ){
                        flag = true;
                        cout << "     250" << endl;
                    }
                    else    cout << "     550" << endl;
                }
                    if( flag )
                        cout << "     DATA" << endl << "     354" << endl << text << "     ." << endl << "     250" << endl;
                    cout << "     QUIT" << endl << "     221" << endl;
            }
            if( !wait.empty() ) wait.clear();
            if( !countnum.empty() ) countnum.clear();
            if( !vec.empty() )  vec.clear();
        }
        return 0;
    }
  • 相关阅读:
    用windows公文包实现不同盘符两个文件文件夹文件同步
    flask0.1版本源码浅析——Request
    flask0.1版源码浅析——url分配处理
    itertools内置库
    nltk简要笔记
    python2.x编码问题-转载
    python函数中的默认参数问题
    中文分词模块--jieba笔记
    模拟登陆国内著名知识交流网站
    http协议简介--转载
  • 原文地址:https://www.cnblogs.com/JinxiSui/p/9740620.html
Copyright © 2020-2023  润新知